package CapaGUI;

import CapaDTO.AM_PRESUDET;
import CapaDTO.CerrarMes;
import CapaDTO.GEN_PROFESIONAL;
import CapaDTO.Pago;
import CapaDTO.Sucursales;
import CapaDTO.Tab_Paciente;
import CapaDTO.TablaOracle;
import CapaDTO.Usuarios;
import CapaNegocio.Negocio;
import CapaNegocio.NegocioInsert;
import Config.Sucursal;
import Config.ToolUtil;
import Config.config;
import java.awt.Button;
import java.awt.Cursor;
import java.awt.Image;
import java.awt.Toolkit;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;
import jxl.CellView;
import jxl.Workbook;
import jxl.format.Alignment;
import jxl.format.Colour;
import jxl.write.*;
import org.jdesktop.swingx.autocomplete.*;

public final class GUI1 extends javax.swing.JFrame {

    /*http://es.debugmodeon.com/articulo/ejecutar-solo-una-instancia-de-una-aplicacion
    http://gustavopeiretti.com/index.php/2009/java-swing-una-sola-instancia/ */
    public GUI1() throws IOException {
        initComponents();
        singleAPP();
        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        this.setLocation(150, 55);
        //ACTUALIZA LAS CONTRASEÑAS SEGUN DATOS DE ORACLE..
        //actualizaContraseñas();
        this.desactiva();
        //tomo la fecha del Computador
        Fecha();
        //lleno los odontologos
       // llenarDoctorPaciente();
        //fijo el foco en Codigo
        this.jtxtUser.requestFocus();
        //fondos...
        cargaFondo();
        //AutoBusqueda---jcombobox---Ingresa
        try {
            AutoCompleteDecorator.decorate(jcboDoctor);
            AutoCompleteDecorator.decorate(jcboDoctorBuscar);
            AutoCompleteDecorator.decorate(jcDetalle);
            AutoCompleteDecorator.decorate(jComboBox5);
            AutoCompleteDecorator.decorate(jComboBox1);
            AutoCompleteDecorator.decorate(jComboBox2);
            AutoCompleteDecorator.decorate(jcbInfo_Odon1);
            AutoCompleteDecorator.decorate(jcbInfo_Odon2);
        } catch (Exception lol) {
        }//System.out.println("");=sout
        //oculto al inicio
        jtOracle.setVisible(false);
        jtAccess.setVisible(false);
        jtverBonos.setVisible(false);
        jTbuscarDoctor.setVisible(false);
        setTitle("Valkyrie Randgris "+ToolUtil.version);
    }
    Negocio neg = new Negocio();
    Date fechaActual = new Date();
    SimpleDateFormat formato = new SimpleDateFormat("yyyyMMdd");
    SimpleDateFormat faño = new SimpleDateFormat("yyyy");
    String FechaDia = formato.format(fechaActual).substring(6, 8);
    String FechaMesActual = formato.format(fechaActual).substring(4, 6);
    String FechaAño = formato.format(fechaActual).substring(0, 4);
    long TotalPagado = 0;
    int TotalRayo = 0;
    long TotalLab = 0;
    int ValorPrestacion = 0;
    int RutPaciente = 0;
    int Bono = 0;
    static ServerSocket serverSocket;
    String Mes[] = {"Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"};
    ArrayList nomproce = new ArrayList();
    ArrayList canti = new ArrayList();

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        Activar = new javax.swing.JFrame();
        jLabel32 = new javax.swing.JLabel();
        jPasswordField1 = new javax.swing.JPasswordField();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        ActivarMes = new javax.swing.JFrame();
        jLabel33 = new javax.swing.JLabel();
        jLabel34 = new javax.swing.JLabel();
        jButton5 = new javax.swing.JButton();
        jComboBox6 = new javax.swing.JComboBox();
        jScrollPane5 = new javax.swing.JScrollPane();
        jTextPane1 = new javax.swing.JTextPane();
        jSpinner1 = new javax.swing.JSpinner();
        ControlAcceso = new javax.swing.JFrame();
        jLabel57 = new javax.swing.JLabel();
        jSeparator11 = new javax.swing.JSeparator();
        jLabel58 = new javax.swing.JLabel();
        jTextField28 = new javax.swing.JTextField();
        jLabel59 = new javax.swing.JLabel();
        jPasswordField4 = new javax.swing.JPasswordField();
        jTextField27 = new javax.swing.JTextField();
        jButton2 = new javax.swing.JButton();
        jSeparator12 = new javax.swing.JSeparator();
        jTabbedPane2 = new javax.swing.JTabbedPane();
        IngUsuario = new javax.swing.JLayeredPane();
        jSeparator14 = new javax.swing.JSeparator();
        jLabel60 = new javax.swing.JLabel();
        jSeparator15 = new javax.swing.JSeparator();
        jSeparator16 = new javax.swing.JSeparator();
        jSeparator17 = new javax.swing.JSeparator();
        jSeparator18 = new javax.swing.JSeparator();
        jSeparator19 = new javax.swing.JSeparator();
        jLabel61 = new javax.swing.JLabel();
        jLabel62 = new javax.swing.JLabel();
        jLabel63 = new javax.swing.JLabel();
        jPasswordField2 = new javax.swing.JPasswordField();
        jLabel64 = new javax.swing.JLabel();
        jPasswordField3 = new javax.swing.JPasswordField();
        jSeparator20 = new javax.swing.JSeparator();
        jLabel66 = new javax.swing.JLabel();
        jTextField32 = new javax.swing.JTextField();
        jLabel67 = new javax.swing.JLabel();
        jTextField33 = new javax.swing.JTextField();
        jLabel68 = new javax.swing.JLabel();
        jTextField34 = new javax.swing.JTextField();
        jLabel69 = new javax.swing.JLabel();
        jTextField31 = new javax.swing.JTextField();
        jLabel70 = new javax.swing.JLabel();
        jSeparator22 = new javax.swing.JSeparator();
        jCheckBox23 = new javax.swing.JCheckBox();
        jCheckBox26 = new javax.swing.JCheckBox();
        jCheckBox16 = new javax.swing.JCheckBox();
        jCheckBox17 = new javax.swing.JCheckBox();
        jCheckBox15 = new javax.swing.JCheckBox();
        jCheckBox14 = new javax.swing.JCheckBox();
        jCheckBox25 = new javax.swing.JCheckBox();
        jCheckBox18 = new javax.swing.JCheckBox();
        jCheckBox20 = new javax.swing.JCheckBox();
        jCheckBox19 = new javax.swing.JCheckBox();
        jCheckBox21 = new javax.swing.JCheckBox();
        jCheckBox24 = new javax.swing.JCheckBox();
        jCheckBox22 = new javax.swing.JCheckBox();
        jLabel71 = new javax.swing.JLabel();
        jTextField30 = new javax.swing.JComboBox();
        jSeparator21 = new javax.swing.JSeparator();
        jbCuGuardar = new javax.swing.JButton();
        jbCuNuevo = new javax.swing.JButton();
        jbCuModificar = new javax.swing.JButton();
        jbcuLimpiar = new javax.swing.JButton();
        jSeparator13 = new javax.swing.JSeparator();
        jbcuEliminar = new javax.swing.JButton();
        jButton9 = new javax.swing.JButton();
        op = new javax.swing.JLabel();
        jlError = new javax.swing.JLabel();
        jfSucursales = new javax.swing.JFrame();
        jLabel47 = new javax.swing.JLabel();
        jtfRetenciSanAntonio = new javax.swing.JTextField();
        jtfPartciSanAntonio = new javax.swing.JTextField();
        jLabelPorcentBandera = new javax.swing.JLabel();
        jTextField26 = new javax.swing.JTextField();
        jTextField29 = new javax.swing.JTextField();
        jLabelPorcentManuelMontt = new javax.swing.JLabel();
        jTextField35 = new javax.swing.JTextField();
        jTextField36 = new javax.swing.JTextField();
        jButton10 = new javax.swing.JButton();
        jButton11 = new javax.swing.JButton();
        jLabel50 = new javax.swing.JLabel();
        jLabel51 = new javax.swing.JLabel();
        jLabel52 = new javax.swing.JLabel();
        jLabel53 = new javax.swing.JLabel();
        jLabel54 = new javax.swing.JLabel();
        jLabel55 = new javax.swing.JLabel();
        jButton12 = new javax.swing.JButton();
        jButton14 = new javax.swing.JButton();
        jLabelPorcentSanAntonio = new javax.swing.JLabel();
        jLabelPorcentLaFlorida = new javax.swing.JLabel();
        jLabel72 = new javax.swing.JLabel();
        jtfRetencionLaFlorida = new javax.swing.JTextField();
        jLabel73 = new javax.swing.JLabel();
        jtfPartiLaFlorida = new javax.swing.JTextField();
        jButton13 = new javax.swing.JButton();
        jLbUser = new javax.swing.JLabel();
        jtxtUser = new javax.swing.JTextField();
        jlbPass = new javax.swing.JLabel();
        jtxtPass = new javax.swing.JPasswordField();
        jBtLogin = new javax.swing.JButton();
        jlbBackgroundLogin = new javax.swing.JLabel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        Ingresar = new javax.swing.JLayeredPane();
        jlOcultarIngreso = new javax.swing.JLabel();
        jlbCodigo = new javax.swing.JLabel();
        jtxtPresupuesto = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jtxtBoleta = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        jtxtValorPresupuesto = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jcDetalle = new javax.swing.JComboBox();
        jlbPago = new javax.swing.JLabel();
        jtxtPago = new javax.swing.JTextField();
        jSeparator3 = new javax.swing.JSeparator();
        jlbDr = new javax.swing.JLabel();
        jcboDoctor = new javax.swing.JComboBox();
        jlbPaciente = new javax.swing.JLabel();
        jtxtPaciente = new javax.swing.JTextField();
        jSeparator2 = new javax.swing.JSeparator();
        jlbLaboratorio1 = new javax.swing.JLabel();
        jcbLaboratorio = new javax.swing.JTextField();
        jlbLaboratorio = new javax.swing.JLabel();
        jtxtRayos = new javax.swing.JTextField();
        jLFecha = new javax.swing.JLabel();
        jTextField14 = new javax.swing.JSpinner();
        jcboFechaIngreso = new javax.swing.JComboBox();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel16 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtAccess = new javax.swing.JTable();
        jLabel14 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jtOracle = new javax.swing.JTable();
        jLabel9 = new javax.swing.JLabel();
        jtxtTotalPagado = new javax.swing.JTextField();
        jLabel39 = new javax.swing.JLabel();
        jtxtTotalLab = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jTextField15 = new javax.swing.JTextField();
        jbtGuardar = new javax.swing.JButton();
        Bonos = new javax.swing.JLayeredPane();
        jLabel27 = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();
        jLabel28 = new javax.swing.JLabel();
        jComboBox2 = new javax.swing.JComboBox();
        jLabel29 = new javax.swing.JLabel();
        jTextField6 = new javax.swing.JTextField();
        jLabel30 = new javax.swing.JLabel();
        jComboBox3 = new javax.swing.JComboBox();
        jSeparator4 = new javax.swing.JSeparator();
        jComboBox4 = new javax.swing.JComboBox();
        jbtVerBono = new javax.swing.JButton();
        jComboBox5 = new javax.swing.JComboBox();
        jScrollPane4 = new javax.swing.JScrollPane();
        jtverBonos = new javax.swing.JTable();
        jtxtAñoBono = new javax.swing.JSpinner();
        jbtGuardarBono = new javax.swing.JButton();
        jTextField7 = new javax.swing.JSpinner();
        ver = new javax.swing.JLayeredPane();
        jLabel4 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jcboDoctorBuscar = new javax.swing.JComboBox();
        jcboFecha = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        jbtBuscarDoctor = new javax.swing.JButton();
        jTextField4 = new javax.swing.JTextField();
        jTextField3 = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jTextField2 = new javax.swing.JTextField();
        jTextField5 = new javax.swing.JTextField();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTbuscarDoctor = new javax.swing.JTable();
        jLabel1 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jTextField16 = new javax.swing.JTextField();
        jLabel23 = new javax.swing.JLabel();
        ver1 = new javax.swing.JLayeredPane();
        jLabel31 = new javax.swing.JLabel();
        jLabel37 = new javax.swing.JLabel();
        jLabel38 = new javax.swing.JLabel();
        jLabel40 = new javax.swing.JLabel();
        jcboDoctorBuscar1 = new javax.swing.JComboBox();
        jtxtAño1 = new javax.swing.JTextField();
        jcboFecha1 = new javax.swing.JComboBox();
        jLabel41 = new javax.swing.JLabel();
        jbtBuscarDoctor1 = new javax.swing.JButton();
        jTextField17 = new javax.swing.JTextField();
        jTextField18 = new javax.swing.JTextField();
        jLabel42 = new javax.swing.JLabel();
        jTextField19 = new javax.swing.JTextField();
        jTextField20 = new javax.swing.JTextField();
        jScrollPane6 = new javax.swing.JScrollPane();
        jTbuscarDoctor1 = new javax.swing.JTable();
        jLabel43 = new javax.swing.JLabel();
        jTextField21 = new javax.swing.JTextField();
        jTextField22 = new javax.swing.JTextField();
        jLabel44 = new javax.swing.JLabel();
        jTextField23 = new javax.swing.JTextField();
        jLabel45 = new javax.swing.JLabel();
        jTextField24 = new javax.swing.JTextField();
        jLabel46 = new javax.swing.JLabel();
        jtxtAño = new javax.swing.JSpinner();
        CerrarMes = new javax.swing.JLayeredPane();
        jlbCerrar_sucursal = new javax.swing.JLabel();
        jcbCerrar_mes = new javax.swing.JComboBox();
        jButton6 = new javax.swing.JButton();
        jtxtCerrar_Año = new javax.swing.JSpinner();
        Informes = new javax.swing.JLayeredPane();
        jLabelSucursalInformes = new javax.swing.JLabel();
        jSeparator5 = new javax.swing.JSeparator();
        jcbInfo_Odon1 = new javax.swing.JComboBox();
        jComboBox7 = new javax.swing.JComboBox();
        jTextField9 = new javax.swing.JSpinner();
        jbtExExcelDr = new javax.swing.JButton();
        jSeparator6 = new javax.swing.JSeparator();
        jcbInfo_Odon2 = new javax.swing.JComboBox();
        jTextField10 = new javax.swing.JSpinner();
        jbtExExcelDr1 = new javax.swing.JButton();
        jSeparator8 = new javax.swing.JSeparator();
        jComboBox8 = new javax.swing.JComboBox();
        jTextField11 = new javax.swing.JSpinner();
        jbtExExcelDr2 = new javax.swing.JButton();
        jSeparator7 = new javax.swing.JSeparator();
        jComboBox9 = new javax.swing.JComboBox();
        jTextField12 = new javax.swing.JSpinner();
        jbtExExcelDr3 = new javax.swing.JButton();
        Sucursales = new javax.swing.JLayeredPane();
        jLabel2 = new javax.swing.JLabel();
        jbtSanAntonio = new javax.swing.JButton();
        jbtBandera = new javax.swing.JButton();
        jbtMontt = new javax.swing.JButton();
        jbtLaFlorida = new javax.swing.JButton();
        jLabelCreador = new javax.swing.JLabel();
        Admin = new javax.swing.JLayeredPane();
        jLabelSucursalAdmin = new javax.swing.JLabel();
        jtbActivarMeses = new javax.swing.JButton();
        jbtConfig = new javax.swing.JButton();
        jbtManUser = new javax.swing.JButton();
        jbtMantSucPorcentaje = new javax.swing.JButton();
        Creditos = new javax.swing.JLayeredPane();
        jLabel17 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        jbtSalir = new javax.swing.JButton();

        Activar.setTitle("Active");
        Activar.setResizable(false);

        jLabel32.setText("Active el Programa");

        jButton3.setText("Activar");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jButton4.setText("Salir");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout ActivarLayout = new javax.swing.GroupLayout(Activar.getContentPane());
        Activar.getContentPane().setLayout(ActivarLayout);
        ActivarLayout.setHorizontalGroup(
            ActivarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ActivarLayout.createSequentialGroup()
                .addGap(47, 47, 47)
                .addGroup(ActivarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(ActivarLayout.createSequentialGroup()
                        .addComponent(jButton3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(55, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, ActivarLayout.createSequentialGroup()
                .addContainerGap(66, Short.MAX_VALUE)
                .addComponent(jLabel32, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(30, 30, 30))
        );
        ActivarLayout.setVerticalGroup(
            ActivarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ActivarLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel32, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(11, 11, 11)
                .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(ActivarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton3)
                    .addComponent(jButton4))
                .addContainerGap(29, Short.MAX_VALUE))
        );

        ActivarMes.setTitle("Reactivar Mes");
        ActivarMes.setResizable(false);

        jLabel33.setText("Mes");

        jLabel34.setText("Año");

        jButton5.setText("Activar MES");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jScrollPane5.setForeground(new java.awt.Color(255, 0, 51));

        jTextPane1.setEditable(false);
        jTextPane1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jTextPane1.setForeground(new java.awt.Color(255, 0, 51));
        jTextPane1.setText("Para abril el mes cerrado se debe contar con las autorizaciones correspondientes. Luego de realizar los cambios se debe cerrar el mes modificado. ");
        jScrollPane5.setViewportView(jTextPane1);

        jSpinner1.setModel(new javax.swing.SpinnerDateModel());
        jSpinner1.setEditor(new javax.swing.JSpinner.DateEditor(jSpinner1, "yyyy"));

        javax.swing.GroupLayout ActivarMesLayout = new javax.swing.GroupLayout(ActivarMes.getContentPane());
        ActivarMes.getContentPane().setLayout(ActivarMesLayout);
        ActivarMesLayout.setHorizontalGroup(
            ActivarMesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ActivarMesLayout.createSequentialGroup()
                .addGroup(ActivarMesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(ActivarMesLayout.createSequentialGroup()
                        .addGap(28, 28, 28)
                        .addGroup(ActivarMesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(ActivarMesLayout.createSequentialGroup()
                                .addGroup(ActivarMesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel33, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel34))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(ActivarMesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jSpinner1)
                                    .addComponent(jComboBox6, 0, 120, Short.MAX_VALUE)))
                            .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 255, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(ActivarMesLayout.createSequentialGroup()
                        .addGap(90, 90, 90)
                        .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(24, Short.MAX_VALUE))
        );
        ActivarMesLayout.setVerticalGroup(
            ActivarMesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ActivarMesLayout.createSequentialGroup()
                .addGap(36, 36, 36)
                .addGroup(ActivarMesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel33)
                    .addComponent(jComboBox6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(28, 28, 28)
                .addGroup(ActivarMesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel34)
                    .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(27, Short.MAX_VALUE))
        );

        ControlAcceso.setTitle("ACC Control De Acceso");
        ControlAcceso.setResizable(false);

        jLabel57.setText("Ingreso de Responsable");

        jLabel58.setText("Usuario");

        jTextField28.setEnabled(false);

        jLabel59.setText("Password");

        jPasswordField4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jPasswordField4ActionPerformed(evt);
            }
        });

        jTextField27.setEnabled(false);

        jButton2.setText("Ingresar");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jSeparator14.setOrientation(javax.swing.SwingConstants.VERTICAL);
        IngUsuario.add(jSeparator14);
        jSeparator14.setBounds(590, 30, 10, 80);

        jLabel60.setText("Identificación del Usuario");
        jLabel60.setEnabled(false);
        IngUsuario.add(jLabel60);
        jLabel60.setBounds(10, 10, 150, 14);
        IngUsuario.add(jSeparator15);
        jSeparator15.setBounds(430, 30, 160, 10);

        jSeparator16.setOrientation(javax.swing.SwingConstants.VERTICAL);
        IngUsuario.add(jSeparator16);
        jSeparator16.setBounds(600, 20, 20, 380);

        jSeparator17.setOrientation(javax.swing.SwingConstants.VERTICAL);
        IngUsuario.add(jSeparator17);
        jSeparator17.setBounds(10, 20, 20, 380);

        jSeparator18.setOrientation(javax.swing.SwingConstants.VERTICAL);
        IngUsuario.add(jSeparator18);
        jSeparator18.setBounds(310, 30, 20, 80);
        IngUsuario.add(jSeparator19);
        jSeparator19.setBounds(140, 20, 460, 10);

        jLabel61.setForeground(new java.awt.Color(0, 51, 255));
        jLabel61.setText("Informacion de Acceso");
        IngUsuario.add(jLabel61);
        jLabel61.setBounds(320, 20, 120, 14);

        jLabel62.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel62.setText("Id. Usuario");
        IngUsuario.add(jLabel62);
        jLabel62.setBounds(330, 40, 90, 14);

        jLabel63.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel63.setText("Ingresar Password");
        IngUsuario.add(jLabel63);
        jLabel63.setBounds(330, 60, 130, 14);

        jPasswordField2.setEnabled(false);
        jPasswordField2.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jPasswordField2KeyTyped(evt);
            }
        });
        IngUsuario.add(jPasswordField2);
        jPasswordField2.setBounds(450, 60, 110, 20);

        jLabel64.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel64.setText("Confirmar Password");
        IngUsuario.add(jLabel64);
        jLabel64.setBounds(330, 80, 130, 14);

        jPasswordField3.setEnabled(false);
        jPasswordField3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jPasswordField3ActionPerformed(evt);
            }
        });
        jPasswordField3.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jPasswordField3FocusLost(evt);
            }
        });
        jPasswordField3.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jPasswordField3KeyTyped(evt);
            }
        });
        IngUsuario.add(jPasswordField3);
        jPasswordField3.setBounds(450, 80, 110, 20);
        IngUsuario.add(jSeparator20);
        jSeparator20.setBounds(310, 110, 280, 20);

        jLabel66.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel66.setText("Apellid Paterno");
        IngUsuario.add(jLabel66);
        jLabel66.setBounds(20, 30, 100, 14);

        jTextField32.setEnabled(false);
        jTextField32.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField32ActionPerformed(evt);
            }
        });
        jTextField32.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextField32FocusLost(evt);
            }
        });
        jTextField32.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextField32KeyTyped(evt);
            }
        });
        IngUsuario.add(jTextField32);
        jTextField32.setBounds(120, 30, 150, 20);

        jLabel67.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel67.setText("Apellido Materno");
        IngUsuario.add(jLabel67);
        jLabel67.setBounds(20, 60, 110, 14);

        jTextField33.setEnabled(false);
        jTextField33.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField33ActionPerformed(evt);
            }
        });
        jTextField33.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextField33FocusLost(evt);
            }
        });
        jTextField33.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextField33KeyTyped(evt);
            }
        });
        IngUsuario.add(jTextField33);
        jTextField33.setBounds(120, 60, 150, 20);

        jLabel68.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel68.setText("Nombres");
        IngUsuario.add(jLabel68);
        jLabel68.setBounds(20, 90, 110, 14);

        jTextField34.setEnabled(false);
        jTextField34.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField34ActionPerformed(evt);
            }
        });
        jTextField34.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextField34FocusLost(evt);
            }
        });
        jTextField34.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextField34KeyTyped(evt);
            }
        });
        IngUsuario.add(jTextField34);
        jTextField34.setBounds(120, 90, 170, 20);

        jLabel69.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel69.setText("Cargo");
        IngUsuario.add(jLabel69);
        jLabel69.setBounds(20, 120, 130, 14);

        jTextField31.setEnabled(false);
        jTextField31.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField31ActionPerformed(evt);
            }
        });
        jTextField31.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextField31FocusLost(evt);
            }
        });
        jTextField31.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextField31KeyTyped(evt);
            }
        });
        IngUsuario.add(jTextField31);
        jTextField31.setBounds(120, 120, 280, 20);

        jLabel70.setText("Privilegios");
        jLabel70.setEnabled(false);
        IngUsuario.add(jLabel70);
        jLabel70.setBounds(20, 150, 60, 14);
        IngUsuario.add(jSeparator22);
        jSeparator22.setBounds(80, 160, 520, 10);

        jCheckBox23.setText("Ver Pagos");
        jCheckBox23.setEnabled(false);
        IngUsuario.add(jCheckBox23);
        jCheckBox23.setBounds(30, 170, 150, 23);

        jCheckBox26.setText("Ver Bonos");
        jCheckBox26.setEnabled(false);
        IngUsuario.add(jCheckBox26);
        jCheckBox26.setBounds(30, 190, 110, 23);

        jCheckBox16.setText("Eliminar Cierre de Mes");
        jCheckBox16.setEnabled(false);
        IngUsuario.add(jCheckBox16);
        jCheckBox16.setBounds(30, 210, 170, 23);

        jCheckBox17.setText("Eliminar Reg");
        jCheckBox17.setEnabled(false);
        IngUsuario.add(jCheckBox17);
        jCheckBox17.setBounds(30, 230, 120, 23);

        jCheckBox15.setText("Cambiar Sucursal");
        jCheckBox15.setEnabled(false);
        IngUsuario.add(jCheckBox15);
        jCheckBox15.setBounds(30, 250, 150, 23);

        jCheckBox14.setText("Agregar Cierre de Mes");
        jCheckBox14.setEnabled(false);
        IngUsuario.add(jCheckBox14);
        jCheckBox14.setBounds(30, 270, 170, 23);

        jCheckBox25.setText("Liquidaciones por Mes");
        jCheckBox25.setEnabled(false);
        IngUsuario.add(jCheckBox25);
        jCheckBox25.setBounds(220, 170, 200, 23);

        jCheckBox18.setText("Liquidaciones por Año");
        jCheckBox18.setEnabled(false);
        IngUsuario.add(jCheckBox18);
        jCheckBox18.setBounds(220, 190, 200, 23);

        jCheckBox20.setText("Liquidaciones todos los Odontologos");
        jCheckBox20.setEnabled(false);
        IngUsuario.add(jCheckBox20);
        jCheckBox20.setBounds(220, 210, 270, 23);

        jCheckBox19.setText("Liquidaciones Gerencia Mes");
        jCheckBox19.setEnabled(false);
        IngUsuario.add(jCheckBox19);
        jCheckBox19.setBounds(220, 230, 240, 23);

        jCheckBox21.setText("Guardar");
        jCheckBox21.setEnabled(false);
        IngUsuario.add(jCheckBox21);
        jCheckBox21.setBounds(220, 250, 130, 23);

        jCheckBox24.setText("Bonos Viaje");
        jCheckBox24.setEnabled(false);
        IngUsuario.add(jCheckBox24);
        jCheckBox24.setBounds(220, 270, 150, 23);

        jCheckBox22.setText("Admin");
        jCheckBox22.setEnabled(false);
        IngUsuario.add(jCheckBox22);
        jCheckBox22.setBounds(480, 170, 100, 23);

        jLabel71.setText("Opciones");
        IngUsuario.add(jLabel71);
        jLabel71.setBounds(20, 300, 70, 14);

        jTextField30.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTextField30MouseClicked(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jTextField30MousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jTextField30MouseReleased(evt);
            }
        });
        jTextField30.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jTextField30ItemStateChanged(evt);
            }
        });
        jTextField30.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField30ActionPerformed(evt);
            }
        });
        IngUsuario.add(jTextField30);
        jTextField30.setBounds(450, 40, 140, 20);
        IngUsuario.add(jSeparator21);
        jSeparator21.setBounds(70, 310, 530, 10);

        jbCuGuardar.setText("Guardar");
        jbCuGuardar.setEnabled(false);
        jbCuGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbCuGuardarActionPerformed(evt);
            }
        });
        IngUsuario.add(jbCuGuardar);
        jbCuGuardar.setBounds(30, 330, 100, 60);

        jbCuNuevo.setText("Nuevo");
        jbCuNuevo.setEnabled(false);
        jbCuNuevo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbCuNuevoActionPerformed(evt);
            }
        });
        IngUsuario.add(jbCuNuevo);
        jbCuNuevo.setBounds(130, 330, 100, 60);

        jbCuModificar.setText("Modificar");
        jbCuModificar.setEnabled(false);
        jbCuModificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbCuModificarActionPerformed(evt);
            }
        });
        IngUsuario.add(jbCuModificar);
        jbCuModificar.setBounds(230, 330, 100, 60);

        jbcuLimpiar.setText("Limpiar");
        jbcuLimpiar.setEnabled(false);
        jbcuLimpiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbcuLimpiarActionPerformed(evt);
            }
        });
        IngUsuario.add(jbcuLimpiar);
        jbcuLimpiar.setBounds(430, 330, 100, 60);
        IngUsuario.add(jSeparator13);
        jSeparator13.setBounds(10, 400, 590, 20);

        jbcuEliminar.setText("Eliminar");
        jbcuEliminar.setEnabled(false);
        jbcuEliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbcuEliminarActionPerformed(evt);
            }
        });
        IngUsuario.add(jbcuEliminar);
        jbcuEliminar.setBounds(330, 330, 100, 60);

        jTabbedPane2.addTab("Usuarios", IngUsuario);

        jButton9.setText("Salir");
        jButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton9ActionPerformed(evt);
            }
        });

        op.setFont(new java.awt.Font("Tahoma", 2, 18)); // NOI18N

        jlError.setForeground(new java.awt.Color(255, 0, 51));

        javax.swing.GroupLayout ControlAccesoLayout = new javax.swing.GroupLayout(ControlAcceso.getContentPane());
        ControlAcceso.getContentPane().setLayout(ControlAccesoLayout);
        ControlAccesoLayout.setHorizontalGroup(
            ControlAccesoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ControlAccesoLayout.createSequentialGroup()
                .addGroup(ControlAccesoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(ControlAccesoLayout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jLabel57, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(4, 4, 4)
                        .addComponent(jSeparator11, javax.swing.GroupLayout.PREFERRED_SIZE, 484, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(ControlAccesoLayout.createSequentialGroup()
                        .addGap(28, 28, 28)
                        .addComponent(jLabel58, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jTextField28, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jTextField27, javax.swing.GroupLayout.PREFERRED_SIZE, 346, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(ControlAccesoLayout.createSequentialGroup()
                        .addGap(28, 28, 28)
                        .addComponent(jLabel59, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jPasswordField4, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jButton2))
                    .addGroup(ControlAccesoLayout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jSeparator12, javax.swing.GroupLayout.PREFERRED_SIZE, 618, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(ControlAccesoLayout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(ControlAccesoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(ControlAccesoLayout.createSequentialGroup()
                                .addGroup(ControlAccesoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(op, javax.swing.GroupLayout.PREFERRED_SIZE, 164, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(ControlAccesoLayout.createSequentialGroup()
                                        .addGap(10, 10, 10)
                                        .addComponent(jlError, javax.swing.GroupLayout.PREFERRED_SIZE, 317, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jButton9, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jTabbedPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 618, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        ControlAccesoLayout.setVerticalGroup(
            ControlAccesoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ControlAccesoLayout.createSequentialGroup()
                .addGap(11, 11, 11)
                .addGroup(ControlAccesoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel57)
                    .addGroup(ControlAccesoLayout.createSequentialGroup()
                        .addGap(4, 4, 4)
                        .addComponent(jSeparator11, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(6, 6, 6)
                .addGroup(ControlAccesoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(ControlAccesoLayout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jLabel58))
                    .addComponent(jTextField28, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextField27, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(6, 6, 6)
                .addGroup(ControlAccesoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(ControlAccesoLayout.createSequentialGroup()
                        .addGap(4, 4, 4)
                        .addComponent(jLabel59))
                    .addGroup(ControlAccesoLayout.createSequentialGroup()
                        .addGap(1, 1, 1)
                        .addGroup(ControlAccesoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jPasswordField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButton2))))
                .addGap(8, 8, 8)
                .addComponent(jSeparator12, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(6, 6, 6)
                .addComponent(jTabbedPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 439, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(ControlAccesoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(ControlAccesoLayout.createSequentialGroup()
                        .addGap(9, 9, 9)
                        .addComponent(jButton9, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(ControlAccesoLayout.createSequentialGroup()
                        .addComponent(op, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jlError, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        jfSucursales.setTitle("% por Sucursal");
        jfSucursales.setResizable(false);

        jLabel47.setFont(new java.awt.Font("Tahoma", 2, 18)); // NOI18N
        jLabel47.setText("San Antonio");

        jtfRetenciSanAntonio.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jtfRetenciSanAntonioKeyTyped(evt);
            }
        });

        jtfPartciSanAntonio.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jtfPartciSanAntonioKeyTyped(evt);
            }
        });

        jLabelPorcentBandera.setFont(new java.awt.Font("Tahoma", 2, 18)); // NOI18N
        jLabelPorcentBandera.setText("Bandera");

        jTextField26.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextField26KeyTyped(evt);
            }
        });

        jTextField29.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextField29KeyTyped(evt);
            }
        });

        jLabelPorcentManuelMontt.setFont(new java.awt.Font("Tahoma", 2, 18)); // NOI18N
        jLabelPorcentManuelMontt.setText("Manuel Montt");

        jTextField35.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextField35KeyTyped(evt);
            }
        });

        jTextField36.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextField36KeyTyped(evt);
            }
        });

        jButton10.setText("Actualizar");
        jButton10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton10ActionPerformed(evt);
            }
        });

        jButton11.setText("Salir");
        jButton11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton11ActionPerformed(evt);
            }
        });

        jLabel50.setText("Ret.");

        jLabel51.setText("Ret.");

        jLabel52.setText("Ret.");

        jLabel53.setText("Part.");

        jLabel54.setText("Part.");

        jLabel55.setText("Part.");

        jButton12.setText("Actualizar");
        jButton12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton12ActionPerformed(evt);
            }
        });

        jButton14.setText("Actualizar");
        jButton14.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton14ActionPerformed(evt);
            }
        });

        jLabelPorcentSanAntonio.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabelPorcentSanAntonio.setForeground(new java.awt.Color(255, 0, 51));

        jLabelPorcentLaFlorida.setFont(new java.awt.Font("Tahoma", 2, 18)); // NOI18N
        jLabelPorcentLaFlorida.setText("La Florida");

        jLabel72.setText("Ret.");

        jtfRetencionLaFlorida.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jtfRetencionLaFloridaKeyTyped(evt);
            }
        });

        jLabel73.setText("Part.");

        jtfPartiLaFlorida.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jtfPartiLaFloridaKeyTyped(evt);
            }
        });

        jButton13.setText("Actualizar");
        jButton13.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton13ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jfSucursalesLayout = new javax.swing.GroupLayout(jfSucursales.getContentPane());
        jfSucursales.getContentPane().setLayout(jfSucursalesLayout);
        jfSucursalesLayout.setHorizontalGroup(
            jfSucursalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jfSucursalesLayout.createSequentialGroup()
                .addContainerGap(108, Short.MAX_VALUE)
                .addComponent(jButton11, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(105, 105, 105))
            .addGroup(jfSucursalesLayout.createSequentialGroup()
                .addGroup(jfSucursalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jfSucursalesLayout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(jfSucursalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jfSucursalesLayout.createSequentialGroup()
                                .addGap(21, 21, 21)
                                .addComponent(jLabel47, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabelPorcentSanAntonio, javax.swing.GroupLayout.PREFERRED_SIZE, 303, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jfSucursalesLayout.createSequentialGroup()
                        .addGap(8, 8, 8)
                        .addComponent(jLabel51, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(2, 2, 2)
                        .addComponent(jtfRetenciSanAntonio, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(20, 20, 20)
                        .addComponent(jLabel53, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, 0)
                        .addComponent(jtfPartciSanAntonio, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(30, 30, 30)
                        .addComponent(jButton14))
                    .addGroup(jfSucursalesLayout.createSequentialGroup()
                        .addGap(30, 30, 30)
                        .addComponent(jLabelPorcentManuelMontt, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jfSucursalesLayout.createSequentialGroup()
                        .addGap(30, 30, 30)
                        .addComponent(jLabelPorcentBandera, javax.swing.GroupLayout.PREFERRED_SIZE, 210, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jfSucursalesLayout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(jfSucursalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jfSucursalesLayout.createSequentialGroup()
                                .addComponent(jLabel52, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, 0)
                                .addComponent(jTextField26, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(20, 20, 20)
                                .addComponent(jLabel54, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, 0)
                                .addComponent(jTextField29, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jfSucursalesLayout.createSequentialGroup()
                                .addComponent(jLabel50, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, 0)
                                .addComponent(jTextField35, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(20, 20, 20)
                                .addComponent(jLabel55, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, 0)
                                .addComponent(jTextField36, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(30, 30, 30)
                        .addGroup(jfSucursalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButton10)
                            .addComponent(jButton12)))
                    .addGroup(jfSucursalesLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jfSucursalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jfSucursalesLayout.createSequentialGroup()
                                .addGap(20, 20, 20)
                                .addComponent(jLabelPorcentLaFlorida, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jfSucursalesLayout.createSequentialGroup()
                                .addComponent(jLabel72, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, 0)
                                .addComponent(jtfRetencionLaFlorida, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(20, 20, 20)
                                .addComponent(jLabel73, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, 0)
                                .addComponent(jtfPartiLaFlorida, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(30, 30, 30)
                                .addComponent(jButton13)))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jfSucursalesLayout.setVerticalGroup(
            jfSucursalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jfSucursalesLayout.createSequentialGroup()
                .addGap(11, 11, 11)
                .addGroup(jfSucursalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel47)
                    .addComponent(jLabelPorcentSanAntonio, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(7, 7, 7)
                .addGroup(jfSucursalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel51, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jtfRetenciSanAntonio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel53, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jtfPartciSanAntonio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton14))
                .addGap(17, 17, 17)
                .addComponent(jLabelPorcentBandera)
                .addGap(18, 18, 18)
                .addGroup(jfSucursalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel52, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextField26, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel54, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextField29, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton12))
                .addGap(17, 17, 17)
                .addComponent(jLabelPorcentManuelMontt)
                .addGap(18, 18, 18)
                .addGroup(jfSucursalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel50, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextField35, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel55, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jfSucursalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jTextField36, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jButton10)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabelPorcentLaFlorida)
                .addGap(18, 18, 18)
                .addGroup(jfSucursalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel72, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jtfRetencionLaFlorida, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel73, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jfSucursalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jtfPartiLaFlorida, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jButton13)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 32, Short.MAX_VALUE)
                .addComponent(jButton11, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jfSucursales.getAccessibleContext().setAccessibleName("Participacion por Sucursal");

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Valkyrie Randgris 1.6");
        setIconImage(getIconImage());
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        jLbUser.setText("Ususario");

        jtxtUser.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtxtUserActionPerformed(evt);
            }
        });
        jtxtUser.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jtxtUserFocusLost(evt);
            }
        });

        jlbPass.setText("Contraseña");

        jtxtPass.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtxtPassActionPerformed(evt);
            }
        });

        jBtLogin.setText("Entrar");
        jBtLogin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtLoginActionPerformed(evt);
            }
        });

        jlbBackgroundLogin.setIcon(new javax.swing.ImageIcon(getClass().getResource("/CapaGUI/logoDarSaludLogin.PNG"))); // NOI18N

        jTabbedPane1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jTabbedPane1.setForeground(new java.awt.Color(0, 0, 51));

        Ingresar.setBorder(new javax.swing.border.MatteBorder(null));
        Ingresar.add(jlOcultarIngreso);
        jlOcultarIngreso.setBounds(0, 0, 720, 570);

        jlbCodigo.setForeground(new java.awt.Color(0, 102, 255));
        jlbCodigo.setText("N° Pres.");
        Ingresar.add(jlbCodigo);
        jlbCodigo.setBounds(10, 10, 60, 20);

        jtxtPresupuesto.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        jtxtPresupuesto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtxtPresupuestoActionPerformed(evt);
            }
        });
        jtxtPresupuesto.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtxtPresupuestoKeyPressed(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jtxtPresupuestoKeyTyped(evt);
            }
        });
        Ingresar.add(jtxtPresupuesto);
        jtxtPresupuesto.setBounds(60, 10, 120, 20);

        jLabel11.setForeground(new java.awt.Color(255, 0, 51));
        jLabel11.setText("N° Boleta ");
        Ingresar.add(jLabel11);
        jLabel11.setBounds(210, 10, 60, 20);

        jtxtBoleta.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        jtxtBoleta.setText("0");
        jtxtBoleta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtxtBoletaActionPerformed(evt);
            }
        });
        jtxtBoleta.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jtxtBoletaKeyTyped(evt);
            }
        });
        Ingresar.add(jtxtBoleta);
        jtxtBoleta.setBounds(270, 10, 130, 20);

        jLabel13.setForeground(new java.awt.Color(0, 102, 255));
        jLabel13.setText("Valor.Pres");
        Ingresar.add(jLabel13);
        jLabel13.setBounds(460, 10, 80, 20);

        jtxtValorPresupuesto.setEditable(false);
        jtxtValorPresupuesto.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        jtxtValorPresupuesto.setText("0");
        jtxtValorPresupuesto.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jtxtValorPresupuestoMouseClicked(evt);
            }
        });
        jtxtValorPresupuesto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtxtValorPresupuestoActionPerformed(evt);
            }
        });
        jtxtValorPresupuesto.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jtxtValorPresupuestoFocusGained(evt);
            }
        });
        jtxtValorPresupuesto.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jtxtValorPresupuestoKeyTyped(evt);
            }
        });
        Ingresar.add(jtxtValorPresupuesto);
        jtxtValorPresupuesto.setBounds(540, 10, 110, 20);

        jLabel8.setForeground(new java.awt.Color(255, 0, 51));
        jLabel8.setText("Detalle");
        Ingresar.add(jLabel8);
        jLabel8.setBounds(10, 40, 120, 20);

        jcDetalle.setEditable(true);
        jcDetalle.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jcDetalleMouseClicked(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jcDetalleMousePressed(evt);
            }
        });
        jcDetalle.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jcDetalleItemStateChanged(evt);
            }
        });
        jcDetalle.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jcDetalleFocusLost(evt);
            }
        });
        jcDetalle.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jcDetalleKeyPressed(evt);
            }
        });
        Ingresar.add(jcDetalle);
        jcDetalle.setBounds(60, 40, 370, 20);

        jlbPago.setForeground(new java.awt.Color(255, 0, 51));
        jlbPago.setText("Liquidado");
        Ingresar.add(jlbPago);
        jlbPago.setBounds(460, 40, 80, 20);

        jtxtPago.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        jtxtPago.setText("0");
        jtxtPago.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtxtPagoActionPerformed(evt);
            }
        });
        jtxtPago.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jtxtPagoFocusGained(evt);
            }
        });
        jtxtPago.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jtxtPagoKeyTyped(evt);
            }
        });
        Ingresar.add(jtxtPago);
        jtxtPago.setBounds(540, 40, 110, 20);
        Ingresar.add(jSeparator3);
        jSeparator3.setBounds(10, 70, 700, 10);

        jlbDr.setForeground(new java.awt.Color(255, 0, 51));
        jlbDr.setText("Odontologo");
        Ingresar.add(jlbDr);
        jlbDr.setBounds(10, 80, 90, 14);

        jcboDoctor.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Doctor" }));
        jcboDoctor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcboDoctorActionPerformed(evt);
            }
        });
        jcboDoctor.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jcboDoctorKeyPressed(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jcboDoctorKeyTyped(evt);
            }
        });
        Ingresar.add(jcboDoctor);
        jcboDoctor.setBounds(20, 100, 360, 20);

        jlbPaciente.setForeground(new java.awt.Color(0, 102, 255));
        jlbPaciente.setText("Paciente");
        Ingresar.add(jlbPaciente);
        jlbPaciente.setBounds(10, 130, 110, 14);

        jtxtPaciente.setEditable(false);
        Ingresar.add(jtxtPaciente);
        jtxtPaciente.setBounds(20, 150, 360, 20);

        jSeparator2.setOrientation(javax.swing.SwingConstants.VERTICAL);
        Ingresar.add(jSeparator2);
        jSeparator2.setBounds(400, 70, 10, 110);

        jlbLaboratorio1.setForeground(new java.awt.Color(255, 0, 51));
        jlbLaboratorio1.setText("Laboratorio");
        Ingresar.add(jlbLaboratorio1);
        jlbLaboratorio1.setBounds(440, 80, 130, 20);

        jcbLaboratorio.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        jcbLaboratorio.setText("0");
        jcbLaboratorio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcbLaboratorioActionPerformed(evt);
            }
        });
        jcbLaboratorio.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jcbLaboratorioFocusGained(evt);
            }
        });
        jcbLaboratorio.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jcbLaboratorioKeyTyped(evt);
            }
        });
        Ingresar.add(jcbLaboratorio);
        jcbLaboratorio.setBounds(540, 80, 110, 20);

        jlbLaboratorio.setForeground(new java.awt.Color(255, 0, 51));
        jlbLaboratorio.setText("Radiografia");
        Ingresar.add(jlbLaboratorio);
        jlbLaboratorio.setBounds(440, 110, 110, 20);

        jtxtRayos.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        jtxtRayos.setText("0");
        jtxtRayos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtxtRayosActionPerformed(evt);
            }
        });
        jtxtRayos.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jtxtRayosFocusGained(evt);
            }
        });
        jtxtRayos.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jtxtRayosKeyTyped(evt);
            }
        });
        Ingresar.add(jtxtRayos);
        jtxtRayos.setBounds(540, 110, 110, 20);

        jLFecha.setForeground(new java.awt.Color(255, 0, 51));
        jLFecha.setText("Fecha");
        Ingresar.add(jLFecha);
        jLFecha.setBounds(440, 140, 140, 20);

        jTextField14.setModel(new javax.swing.SpinnerDateModel());
        jTextField14.setEditor(new javax.swing.JSpinner.DateEditor(jTextField14, "yyyy"));
        jTextField14.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jTextField14StateChanged(evt);
            }
        });
        jTextField14.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTextField14KeyPressed(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextField14KeyTyped(evt);
            }
        });
        Ingresar.add(jTextField14);
        jTextField14.setBounds(540, 140, 50, 20);

        jcboFechaIngreso.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "MES", " " }));
        jcboFechaIngreso.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcboFechaIngresoActionPerformed(evt);
            }
        });
        Ingresar.add(jcboFechaIngreso);
        jcboFechaIngreso.setBounds(590, 140, 80, 20);
        Ingresar.add(jSeparator1);
        jSeparator1.setBounds(10, 190, 700, 10);

        jLabel16.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
        jLabel16.setForeground(new java.awt.Color(255, 0, 51));
        jLabel16.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabel16.setText("Sucursal");
        Ingresar.add(jLabel16);
        jLabel16.setBounds(10, 190, 340, 30);

        jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

        jtAccess.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        jtAccess.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jtAccessMouseReleased(evt);
            }
        });
        jScrollPane1.setViewportView(jtAccess);

        Ingresar.add(jScrollPane1);
        jScrollPane1.setBounds(10, 220, 700, 130);

        jLabel14.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
        jLabel14.setForeground(new java.awt.Color(0, 102, 255));
        jLabel14.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabel14.setText("Oracle Medisyn  ");
        Ingresar.add(jLabel14);
        jLabel14.setBounds(10, 350, 260, 40);

        jScrollPane3.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
        jScrollPane3.setEnabled(false);

        jtOracle.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        jScrollPane3.setViewportView(jtOracle);

        Ingresar.add(jScrollPane3);
        jScrollPane3.setBounds(10, 380, 700, 130);

        jLabel9.setForeground(new java.awt.Color(255, 0, 51));
        jLabel9.setText("T. Pag");
        Ingresar.add(jLabel9);
        jLabel9.setBounds(10, 530, 60, 20);

        jtxtTotalPagado.setEditable(false);
        jtxtTotalPagado.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        jtxtTotalPagado.setText("0");
        Ingresar.add(jtxtTotalPagado);
        jtxtTotalPagado.setBounds(50, 530, 80, 20);

        jLabel39.setForeground(new java.awt.Color(255, 0, 51));
        jLabel39.setText("T. Lab");
        Ingresar.add(jLabel39);
        jLabel39.setBounds(150, 530, 60, 20);

        jtxtTotalLab.setEditable(false);
        jtxtTotalLab.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        jtxtTotalLab.setText("0");
        Ingresar.add(jtxtTotalLab);
        jtxtTotalLab.setBounds(190, 530, 80, 20);

        jLabel12.setForeground(new java.awt.Color(255, 0, 51));
        jLabel12.setText("T. Rayos");
        Ingresar.add(jLabel12);
        jLabel12.setBounds(300, 530, 60, 20);

        jTextField15.setEditable(false);
        jTextField15.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        jTextField15.setText("0");
        Ingresar.add(jTextField15);
        jTextField15.setBounds(360, 530, 80, 20);

        jbtGuardar.setText("Guardar");
        jbtGuardar.setEnabled(false);
        jbtGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtGuardarActionPerformed(evt);
            }
        });
        Ingresar.add(jbtGuardar);
        jbtGuardar.setBounds(560, 520, 150, 30);

        jTabbedPane1.addTab("Ingresar", Ingresar);

        jLabel27.setForeground(new java.awt.Color(255, 0, 51));
        jLabel27.setText("Odontologo");
        Bonos.add(jLabel27);
        jLabel27.setBounds(310, 30, 100, 14);

        jComboBox1.setEditable(true);
        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Bono de Viaje Odontologo" }));
        Bonos.add(jComboBox1);
        jComboBox1.setBounds(180, 100, 330, 20);

        jLabel28.setForeground(new java.awt.Color(255, 0, 51));
        jLabel28.setText("Bonos");
        Bonos.add(jLabel28);
        jLabel28.setBounds(320, 80, 70, 14);

        Bonos.add(jComboBox2);
        jComboBox2.setBounds(20, 280, 330, 20);

        jLabel29.setForeground(new java.awt.Color(255, 0, 51));
        jLabel29.setText("Cantidad");
        Bonos.add(jLabel29);
        jLabel29.setBounds(210, 130, 100, 14);

        jTextField6.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        jTextField6.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextField6KeyTyped(evt);
            }
        });
        Bonos.add(jTextField6);
        jTextField6.setBounds(170, 150, 140, 20);

        jLabel30.setForeground(new java.awt.Color(255, 0, 51));
        jLabel30.setText("Fecha");
        Bonos.add(jLabel30);
        jLabel30.setBounds(380, 130, 80, 14);

        Bonos.add(jComboBox3);
        jComboBox3.setBounds(380, 280, 120, 20);
        Bonos.add(jSeparator4);
        jSeparator4.setBounds(0, 240, 720, 10);

        Bonos.add(jComboBox4);
        jComboBox4.setBounds(340, 150, 120, 20);

        jbtVerBono.setText("Ver");
        jbtVerBono.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtVerBonoActionPerformed(evt);
            }
        });
        Bonos.add(jbtVerBono);
        jbtVerBono.setBounds(620, 280, 80, 20);

        Bonos.add(jComboBox5);
        jComboBox5.setBounds(180, 50, 330, 20);

        jScrollPane4.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

        jtverBonos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        jScrollPane4.setViewportView(jtverBonos);

        Bonos.add(jScrollPane4);
        jScrollPane4.setBounds(20, 320, 680, 230);

        jtxtAñoBono.setModel(new javax.swing.SpinnerDateModel(new java.util.Date(), null, null, java.util.Calendar.YEAR));
        jtxtAñoBono.setEditor(new javax.swing.JSpinner.DateEditor(jtxtAñoBono, "yyyy"));
        Bonos.add(jtxtAñoBono);
        jtxtAñoBono.setBounds(470, 150, 70, 20);

        jbtGuardarBono.setText("Guardar");
        jbtGuardarBono.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtGuardarBonoActionPerformed1(evt);
            }
        });
        Bonos.add(jbtGuardarBono);
        jbtGuardarBono.setBounds(280, 190, 140, 40);

        jTextField7.setModel(new javax.swing.SpinnerDateModel());
        jTextField7.setEditor(new javax.swing.JSpinner.DateEditor(jTextField7, "yyyy"));
        Bonos.add(jTextField7);
        jTextField7.setBounds(530, 280, 70, 20);

        jTabbedPane1.addTab("Bonos", Bonos);

        jLabel4.setText("RETENCION  10%  ");
        ver.add(jLabel4);
        jLabel4.setBounds(240, 490, 160, 14);

        jLabel3.setText("HONORARIOS  50% ");
        ver.add(jLabel3);
        jLabel3.setBounds(240, 460, 180, 14);

        jLabel5.setText("SUMA DEL MES");
        ver.add(jLabel5);
        jLabel5.setBounds(20, 460, 150, 14);

        jLabel6.setText("Nombre Doctor");
        ver.add(jLabel6);
        jLabel6.setBounds(10, 20, 110, 10);

        ver.add(jcboDoctorBuscar);
        jcboDoctorBuscar.setBounds(10, 40, 370, 20);

        jcboFecha.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "MES", " " }));
        jcboFecha.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcboFechaActionPerformed(evt);
            }
        });
        ver.add(jcboFecha);
        jcboFecha.setBounds(10, 90, 90, 20);

        jLabel7.setText("Fecha");
        ver.add(jLabel7);
        jLabel7.setBounds(10, 70, 60, 14);

        jbtBuscarDoctor.setText("Buscar");
        jbtBuscarDoctor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtBuscarDoctorActionPerformed(evt);
            }
        });
        ver.add(jbtBuscarDoctor);
        jbtBuscarDoctor.setBounds(220, 80, 150, 30);

        jTextField4.setEditable(false);
        ver.add(jTextField4);
        jTextField4.setBounds(530, 490, 120, 20);

        jTextField3.setEditable(false);
        ver.add(jTextField3);
        jTextField3.setBounds(360, 490, 130, 20);

        jLabel10.setText("TOTAL LIQUIDADO");
        ver.add(jLabel10);
        jLabel10.setBounds(530, 470, 150, 14);

        jTextField2.setEditable(false);
        ver.add(jTextField2);
        jTextField2.setBounds(360, 460, 130, 20);

        jTextField5.setEditable(false);
        ver.add(jTextField5);
        jTextField5.setBounds(110, 460, 120, 20);

        jScrollPane2.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
        jScrollPane2.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
        jScrollPane2.setAutoscrolls(true);

        jTbuscarDoctor.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        jScrollPane2.setViewportView(jTbuscarDoctor);

        ver.add(jScrollPane2);
        jScrollPane2.setBounds(10, 130, 710, 310);

        jLabel1.setText("Sucursal: ");
        ver.add(jLabel1);
        jLabel1.setBounds(440, 20, 110, 14);

        jTextField1.setEditable(false);
        jTextField1.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
        jTextField1.setForeground(new java.awt.Color(255, 0, 51));
        jTextField1.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jTextField1.setText("Sucursal");
        ver.add(jTextField1);
        jTextField1.setBounds(440, 40, 170, 30);

        jTextField16.setEditable(false);
        ver.add(jTextField16);
        jTextField16.setBounds(110, 490, 120, 20);

        jLabel23.setText("SUMA BONOS");
        ver.add(jLabel23);
        jLabel23.setBounds(20, 490, 90, 14);

        jLabel31.setText("RETENCION  10%  ");
        ver1.add(jLabel31);
        jLabel31.setBounds(240, 490, 160, 14);

        jLabel37.setText("HONORARIOS S/  50% ");
        ver1.add(jLabel37);
        jLabel37.setBounds(240, 460, 180, 14);

        jLabel38.setText("SUMA DEL MES");
        ver1.add(jLabel38);
        jLabel38.setBounds(20, 460, 150, 14);

        jLabel40.setText("Nombre Doctor");
        ver1.add(jLabel40);
        jLabel40.setBounds(10, 20, 110, 10);

        ver1.add(jcboDoctorBuscar1);
        jcboDoctorBuscar1.setBounds(10, 40, 360, 20);

        jtxtAño1.setText("Año");
        jtxtAño1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtxtAño1ActionPerformed(evt);
            }
        });
        jtxtAño1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jtxtAño1KeyTyped(evt);
            }
        });
        ver1.add(jtxtAño1);
        jtxtAño1.setBounds(120, 90, 60, 20);

        jcboFecha1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "MES", " " }));
        jcboFecha1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcboFecha1ActionPerformed(evt);
            }
        });
        ver1.add(jcboFecha1);
        jcboFecha1.setBounds(10, 90, 90, 20);

        jLabel41.setText("Fecha");
        ver1.add(jLabel41);
        jLabel41.setBounds(10, 70, 60, 14);

        jbtBuscarDoctor1.setText("Buscar");
        jbtBuscarDoctor1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtBuscarDoctor1ActionPerformed(evt);
            }
        });
        ver1.add(jbtBuscarDoctor1);
        jbtBuscarDoctor1.setBounds(210, 80, 150, 30);

        jTextField17.setEditable(false);
        ver1.add(jTextField17);
        jTextField17.setBounds(530, 490, 120, 20);

        jTextField18.setEditable(false);
        ver1.add(jTextField18);
        jTextField18.setBounds(360, 490, 130, 20);

        jLabel42.setText("TOTAL LIQUIDADO");
        ver1.add(jLabel42);
        jLabel42.setBounds(530, 470, 150, 14);

        jTextField19.setEditable(false);
        ver1.add(jTextField19);
        jTextField19.setBounds(360, 460, 130, 20);

        jTextField20.setEditable(false);
        ver1.add(jTextField20);
        jTextField20.setBounds(110, 460, 120, 20);

        jScrollPane6.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
        jScrollPane6.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
        jScrollPane6.setAutoscrolls(true);

        jTbuscarDoctor1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null}
            },
            new String [] {
                "Fecha", "Paciente", "Descripcion", "Laboratorio", "Bono", "Liquidado", "Boleta"
            }
        ));
        jScrollPane6.setViewportView(jTbuscarDoctor1);

        ver1.add(jScrollPane6);
        jScrollPane6.setBounds(10, 130, 710, 310);

        jLabel43.setText("Sucursal: ");
        ver1.add(jLabel43);
        jLabel43.setBounds(440, 20, 110, 14);

        jTextField21.setEditable(false);
        jTextField21.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
        jTextField21.setForeground(new java.awt.Color(255, 0, 51));
        jTextField21.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jTextField21.setText("Sucursal");
        ver1.add(jTextField21);
        jTextField21.setBounds(440, 40, 170, 30);

        jTextField22.setEditable(false);
        ver1.add(jTextField22);
        jTextField22.setBounds(110, 490, 120, 20);

        jLabel44.setText("SUMA BONOS");
        ver1.add(jLabel44);
        jLabel44.setBounds(20, 490, 90, 14);

        ver.add(ver1);
        ver1.setBounds(0, 0, 0, 0);

        jTextField23.setEditable(false);
        ver.add(jTextField23);
        jTextField23.setBounds(360, 520, 130, 20);

        jLabel45.setText("SUMA LABORATORIO");
        ver.add(jLabel45);
        jLabel45.setBounds(240, 520, 160, 14);

        jTextField24.setEditable(false);
        ver.add(jTextField24);
        jTextField24.setBounds(110, 520, 120, 20);

        jLabel46.setText("SUMA RAYOS");
        ver.add(jLabel46);
        jLabel46.setBounds(20, 520, 90, 14);

        jtxtAño.setModel(new javax.swing.SpinnerDateModel());
        jtxtAño.setEditor(new javax.swing.JSpinner.DateEditor(jtxtAño, "yyyy"));
        ver.add(jtxtAño);
        jtxtAño.setBounds(120, 90, 60, 20);

        jTabbedPane1.addTab("Ver Liquidacion", ver);

        jlbCerrar_sucursal.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
        jlbCerrar_sucursal.setForeground(new java.awt.Color(255, 0, 51));
        jlbCerrar_sucursal.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jlbCerrar_sucursal.setText("Sucursal");
        CerrarMes.add(jlbCerrar_sucursal);
        jlbCerrar_sucursal.setBounds(210, 30, 260, 60);

        jcbCerrar_mes.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        CerrarMes.add(jcbCerrar_mes);
        jcbCerrar_mes.setBounds(240, 160, 210, 30);

        jButton6.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jButton6.setText("Cerrar Mes");
        jButton6.setEnabled(false);
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });
        CerrarMes.add(jButton6);
        jButton6.setBounds(270, 290, 160, 40);

        jtxtCerrar_Año.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
        jtxtCerrar_Año.setModel(new javax.swing.SpinnerDateModel());
        jtxtCerrar_Año.setEditor(new javax.swing.JSpinner.DateEditor(jtxtCerrar_Año, "yyyy"));
        CerrarMes.add(jtxtCerrar_Año);
        jtxtCerrar_Año.setBounds(240, 210, 210, 50);

        jTabbedPane1.addTab("Cerrar Mes", CerrarMes);

        jLabelSucursalInformes.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
        jLabelSucursalInformes.setForeground(new java.awt.Color(255, 0, 51));
        jLabelSucursalInformes.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabelSucursalInformes.setText("Sucursal");
        Informes.add(jLabelSucursalInformes);
        jLabelSucursalInformes.setBounds(210, 30, 260, 60);
        Informes.add(jSeparator5);
        jSeparator5.setBounds(10, 90, 700, 10);

        Informes.add(jcbInfo_Odon1);
        jcbInfo_Odon1.setBounds(100, 110, 430, 20);

        Informes.add(jComboBox7);
        jComboBox7.setBounds(400, 160, 130, 20);

        jTextField9.setModel(new javax.swing.SpinnerDateModel());
        jTextField9.setEditor(new javax.swing.JSpinner.DateEditor(jTextField9, "yyyy"));
        Informes.add(jTextField9);
        jTextField9.setBounds(320, 160, 50, 20);

        jbtExExcelDr.setIcon(new javax.swing.ImageIcon(getClass().getResource("/CapaGUI/xls2.jpg"))); // NOI18N
        jbtExExcelDr.setText("Liquidaciones por Mes");
        jbtExExcelDr.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtExExcelDrActionPerformed(evt);
            }
        });
        Informes.add(jbtExExcelDr);
        jbtExExcelDr.setBounds(100, 150, 210, 40);
        Informes.add(jSeparator6);
        jSeparator6.setBounds(10, 210, 700, 10);

        Informes.add(jcbInfo_Odon2);
        jcbInfo_Odon2.setBounds(100, 230, 430, 20);

        jTextField10.setModel(new javax.swing.SpinnerDateModel());
        jTextField10.setEditor(new javax.swing.JSpinner.DateEditor(jTextField10, "yyyy"));
        Informes.add(jTextField10);
        jTextField10.setBounds(320, 280, 50, 20);

        jbtExExcelDr1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/CapaGUI/xls2.jpg"))); // NOI18N
        jbtExExcelDr1.setText("Liquidaciones por Año");
        jbtExExcelDr1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtExExcelDr1ActionPerformed(evt);
            }
        });
        Informes.add(jbtExExcelDr1);
        jbtExExcelDr1.setBounds(100, 270, 210, 40);
        Informes.add(jSeparator8);
        jSeparator8.setBounds(10, 330, 700, 20);

        Informes.add(jComboBox8);
        jComboBox8.setBounds(390, 360, 140, 20);

        jTextField11.setModel(new javax.swing.SpinnerDateModel());
        jTextField11.setEditor(new javax.swing.JSpinner.DateEditor(jTextField11, "yyyy"));
        Informes.add(jTextField11);
        jTextField11.setBounds(320, 360, 50, 20);

        jbtExExcelDr2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/CapaGUI/xls2.jpg"))); // NOI18N
        jbtExExcelDr2.setText("Todos los Odontologos");
        jbtExExcelDr2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtExExcelDr2ActionPerformed1(evt);
            }
        });
        Informes.add(jbtExExcelDr2);
        jbtExExcelDr2.setBounds(100, 350, 210, 40);
        Informes.add(jSeparator7);
        jSeparator7.setBounds(10, 410, 700, 20);

        Informes.add(jComboBox9);
        jComboBox9.setBounds(390, 440, 140, 20);

        jTextField12.setModel(new javax.swing.SpinnerDateModel());
        jTextField12.setEditor(new javax.swing.JSpinner.DateEditor(jTextField12, "yyyy"));
        Informes.add(jTextField12);
        jTextField12.setBounds(320, 440, 50, 20);

        jbtExExcelDr3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/CapaGUI/xls2.jpg"))); // NOI18N
        jbtExExcelDr3.setText("Gerencia  Mes             ");
        jbtExExcelDr3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtExExcelDr3ActionPerformed(evt);
            }
        });
        Informes.add(jbtExExcelDr3);
        jbtExExcelDr3.setBounds(100, 430, 210, 40);

        jTabbedPane1.addTab("Informes", Informes);

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
        jLabel2.setForeground(new java.awt.Color(255, 0, 51));
        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel2.setText("Sucursal");
        Sucursales.add(jLabel2);
        jLabel2.setBounds(210, 30, 260, 60);

        jbtSanAntonio.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jbtSanAntonio.setText("San Antonio");
        jbtSanAntonio.setEnabled(false);
        jbtSanAntonio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtSanAntonioActionPerformed(evt);
            }
        });
        Sucursales.add(jbtSanAntonio);
        jbtSanAntonio.setBounds(190, 150, 300, 60);

        jbtBandera.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jbtBandera.setText("Bandera");
        jbtBandera.setEnabled(false);
        jbtBandera.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtBanderaActionPerformed(evt);
            }
        });
        Sucursales.add(jbtBandera);
        jbtBandera.setBounds(190, 240, 300, 60);

        jbtMontt.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jbtMontt.setText("Manuel Montt");
        jbtMontt.setEnabled(false);
        jbtMontt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtMonttActionPerformed(evt);
            }
        });
        Sucursales.add(jbtMontt);
        jbtMontt.setBounds(190, 330, 300, 60);

        jbtLaFlorida.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jbtLaFlorida.setText("La Florida");
        jbtLaFlorida.setEnabled(false);
        jbtLaFlorida.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtLaFloridaActionPerformed(evt);
            }
        });
        Sucursales.add(jbtLaFlorida);
        jbtLaFlorida.setBounds(190, 420, 300, 60);

        jLabelCreador.setForeground(new java.awt.Color(255, 255, 255));
        jLabelCreador.setText("creator by Jorge Luis Valdivia López");
        Sucursales.add(jLabelCreador);
        jLabelCreador.setBounds(10, 540, 370, 14);

        jTabbedPane1.addTab("Sucursales", Sucursales);

        jLabelSucursalAdmin.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
        jLabelSucursalAdmin.setForeground(new java.awt.Color(255, 0, 0));
        jLabelSucursalAdmin.setText("Administración");
        Admin.add(jLabelSucursalAdmin);
        jLabelSucursalAdmin.setBounds(220, 30, 260, 60);

        jtbActivarMeses.setText("Activar Mes");
        jtbActivarMeses.setEnabled(false);
        jtbActivarMeses.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtbActivarMesesActionPerformed(evt);
            }
        });
        Admin.add(jtbActivarMeses);
        jtbActivarMeses.setBounds(250, 190, 180, 50);

        jbtConfig.setText("Configuracion");
        jbtConfig.setEnabled(false);
        jbtConfig.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtConfigActionPerformed(evt);
            }
        });
        Admin.add(jbtConfig);
        jbtConfig.setBounds(250, 260, 180, 50);

        jbtManUser.setText("Mantenedor User.");
        jbtManUser.setEnabled(false);
        jbtManUser.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtManUserActionPerformed(evt);
            }
        });
        Admin.add(jbtManUser);
        jbtManUser.setBounds(250, 120, 180, 50);

        jbtMantSucPorcentaje.setText("Part. por Sucursal");
        jbtMantSucPorcentaje.setEnabled(false);
        jbtMantSucPorcentaje.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtMantSucPorcentajeActionPerformed(evt);
            }
        });
        Admin.add(jbtMantSucPorcentaje);
        jbtMantSucPorcentaje.setBounds(250, 330, 180, 50);

        jTabbedPane1.addTab("Administrador", Admin);

        jLabel17.setFont(new java.awt.Font("Tahoma", 0, 20)); // NOI18N
        jLabel17.setForeground(new java.awt.Color(255, 255, 255));
        jLabel17.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel17.setText("(jorge.valdivia.lopez@gmail.com)");
        Creditos.add(jLabel17);
        jLabel17.setBounds(0, 280, 720, 50);

        jLabel24.setFont(new java.awt.Font("Tahoma", 0, 20)); // NOI18N
        jLabel24.setForeground(new java.awt.Color(255, 255, 255));
        jLabel24.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel24.setText("Creado por Jorge Luis Valdivia López");
        Creditos.add(jLabel24);
        jLabel24.setBounds(0, 240, 720, 50);

        jLabel18.setIcon(new javax.swing.ImageIcon(getClass().getResource("/CapaGUI/logoDarSalud.PNG"))); // NOI18N
        Creditos.add(jLabel18);
        jLabel18.setBounds(0, 7, 230, 90);
        Creditos.add(jLabel25);
        jLabel25.setBounds(0, 0, 730, 560);

        jTabbedPane1.addTab("Acerca de..", Creditos);

        jbtSalir.setText("Salir");
        jbtSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtSalirActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(247, 247, 247)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(40, 40, 40)
                        .addComponent(jLbUser, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jtxtUser, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(30, 30, 30)
                        .addComponent(jlbPass, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtxtPass, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(150, 150, 150)
                        .addComponent(jBtLogin))
                    .addComponent(jlbBackgroundLogin))
                .addContainerGap(253, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(663, Short.MAX_VALUE)
                .addComponent(jbtSalir, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 733, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(14, Short.MAX_VALUE)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(162, 162, 162)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(100, 100, 100)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jtxtUser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLbUser))
                        .addGap(10, 10, 10)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jtxtPass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(10, 10, 10)
                                .addComponent(jBtLogin))
                            .addComponent(jlbPass)))
                    .addComponent(jlbBackgroundLogin))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 295, Short.MAX_VALUE)
                .addComponent(jbtSalir)
                .addContainerGap())
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 597, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(75, Short.MAX_VALUE)))
        );

        getAccessibleContext().setAccessibleName("Valkyrie");

        pack();
    }// </editor-fold>//GEN-END:initComponents

    @Override
    public Image getIconImage() {
        Image retValue = Toolkit.getDefaultToolkit().
                getImage(ClassLoader.getSystemResource("CapaGUI/shacra.png"));
        return retValue;
    }

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        this.salir();
    }//GEN-LAST:event_formWindowClosing

    private void jcbLaboratorioKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jcbLaboratorioKeyTyped
        char letra = evt.getKeyChar();

        if (letra > '9') {
            evt.consume();
        } else {
            if (this.jcbLaboratorio.getText().trim().length() > 7) {
                evt.consume();
            }
        }
}//GEN-LAST:event_jcbLaboratorioKeyTyped

    private void jcbLaboratorioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbLaboratorioActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_jcbLaboratorioActionPerformed

    private void jtxtBoletaKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtxtBoletaKeyTyped
        // TODO add your handling code here:
        char letra = evt.getKeyChar();
        if (letra < '0' || letra > '9') {
            evt.consume();
        } else {
            if (this.jtxtBoleta.getText().trim().length() > 6) {
                evt.consume();
            }
        }
}//GEN-LAST:event_jtxtBoletaKeyTyped

    private void jtxtBoletaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtxtBoletaActionPerformed
        this.jcDetalle.requestFocus();
}//GEN-LAST:event_jtxtBoletaActionPerformed

    private void jcboDoctorKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jcboDoctorKeyTyped
}//GEN-LAST:event_jcboDoctorKeyTyped

    private void jcboDoctorKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jcboDoctorKeyPressed
}//GEN-LAST:event_jcboDoctorKeyPressed

    private void jcboDoctorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcboDoctorActionPerformed
}//GEN-LAST:event_jcboDoctorActionPerformed

    private void jtxtValorPresupuestoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtxtValorPresupuestoKeyTyped
        // TODO add your handling code here:
        char letra = evt.getKeyChar();
        if (letra < '0' || letra > '9') {
            evt.consume();
        } else {
            if (this.jtxtValorPresupuesto.getText().trim().length() > 9) {
                evt.consume();
            }
        }
}//GEN-LAST:event_jtxtValorPresupuestoKeyTyped

    private void jtxtValorPresupuestoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtxtValorPresupuestoActionPerformed
        // TODO add your handling code here:
        //this.jtxtDetalle.requestFocus();
}//GEN-LAST:event_jtxtValorPresupuestoActionPerformed

    private void jtxtValorPresupuestoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jtxtValorPresupuestoMouseClicked
        // TODO add your handling code here:
}//GEN-LAST:event_jtxtValorPresupuestoMouseClicked

    private void jbtGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtGuardarActionPerformed
        /*1 confirmar si devo agregar una nueva prestacion*/
        if (this.jtxtPago.getText().isEmpty()) {
            this.jtxtPago.setText("0");
        }
        if (this.jcbLaboratorio.getText().isEmpty()) {
            this.jcbLaboratorio.setText("0");
        }
        if (this.jtxtRayos.getText().isEmpty()) {
            this.jtxtRayos.setText("0");
        }

        boolean validar = true;

        if (!this.jtxtPresupuesto.getText().trim().isEmpty()) {
        } else {
            validar = false;
            JOptionPane.showMessageDialog(this,
                    "No se a Ingresado N° Presupuesto",
                    "Error",
                    JOptionPane.WARNING_MESSAGE);
            this.jtxtPresupuesto.requestFocus();
        }

        if (!this.jtxtBoleta.getText().trim().isEmpty()) {
        } else {
            validar = false;
            JOptionPane.showMessageDialog(this,
                    "No se a Ingresado el N° de Boleta",
                    "Error",
                    JOptionPane.WARNING_MESSAGE);
            this.jtxtBoleta.requestFocus();
        }
        if (!this.jcDetalle.getSelectedItem().toString().trim().isEmpty()) {
        } else {
            validar = false;
            JOptionPane.showMessageDialog(this,
                    "No se a Ingresado Detalle del Pago",
                    "Error",
                    JOptionPane.WARNING_MESSAGE);
            this.jcDetalle.requestFocus();
        }

        if (!this.jcboDoctor.getSelectedItem().toString().trim().isEmpty()) {
        } else {
            validar = false;
            JOptionPane.showMessageDialog(this,
                    "No se a Selecionado un Odontologo",
                    "Error",
                    JOptionPane.WARNING_MESSAGE);
            this.jcboDoctor.requestFocus();
        }
        if (!this.jcboDoctor.getSelectedItem().toString().equalsIgnoreCase("Selecione Odontologo")) {
        } else {
            validar = false;
            JOptionPane.showMessageDialog(this,
                    "No se a Selecionado un Odontologo",
                    "Error",
                    JOptionPane.WARNING_MESSAGE);
            this.jcboDoctor.requestFocus();
        }

        if (validar) {
            //guardar
            //comprobar que la liquidacion no sea mayor al pago
            //validar que el DR exista..
            try {
                Guardar(this.jcboDoctor.getSelectedItem().toString());
            } catch (Exception ex) {
                System.out.print(ex);
            }
        }
}//GEN-LAST:event_jbtGuardarActionPerformed

    private void jtxtPresupuestoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtxtPresupuestoKeyTyped
        // TODO add your handling code here:
        char letra = evt.getKeyChar();

        if (letra < '0' || letra > '9') {
            evt.consume();
        } else {
            if (this.jtxtPresupuesto.getText().trim().length() > 6) {
                evt.consume();
            }
        }
}//GEN-LAST:event_jtxtPresupuestoKeyTyped

    private void jtxtPresupuestoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtxtPresupuestoKeyPressed
}//GEN-LAST:event_jtxtPresupuestoKeyPressed

    private void jtxtPresupuestoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtxtPresupuestoActionPerformed
        //        // TODO add your handling code here:
        //        //BUSCAR EL PRESU EN ORACLE
        setCursor(new Cursor(Cursor.WAIT_CURSOR));
        if (this.jtxtPresupuesto.getText().equalsIgnoreCase("0")) {
            this.jtxtPresupuesto.setText(null);
        }
        this.jtxtBoleta.requestFocus();
        this.jtxtBoleta.setText("");
        this.jtxtPago.setText("");
        this.jcbLaboratorio.setText("");
        this.jtxtRayos.setText("");
        buscaPresu();
        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}//GEN-LAST:event_jtxtPresupuestoActionPerformed

    private void jtxtPagoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtxtPagoKeyTyped
        // TODO add your handling code here:
        char letra = evt.getKeyChar();

        if (letra > '9') {
            evt.consume();
        } else {
            if (this.jtxtPago.getText().trim().length() > 7) {
                evt.consume();
            }
        }
}//GEN-LAST:event_jtxtPagoKeyTyped

    private void jtxtPagoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtxtPagoActionPerformed
        // TODO add your handling code here:
        if (this.jtxtPago.getText().isEmpty()) {
            this.jtxtPago.setText("0");
        }
        if (this.jcbLaboratorio.getText().isEmpty()) {
            this.jcbLaboratorio.setText("0");
        }
        if (this.jtxtRayos.getText().isEmpty()) {
            this.jtxtRayos.setText("0");
        }
        boolean validar = true;

        if (!this.jtxtPresupuesto.getText().trim().isEmpty()) {
        } else {
            validar = false;
            JOptionPane.showMessageDialog(this,
                    "No se a Ingresado N° Presupuesto",
                    "Error",
                    JOptionPane.WARNING_MESSAGE);
            this.jtxtPresupuesto.requestFocus();
        }

        if (!this.jtxtBoleta.getText().trim().isEmpty()) {
        } else {
            validar = false;
            JOptionPane.showMessageDialog(this,
                    "No se a Ingresado el N° de Boleta",
                    "Error",
                    JOptionPane.WARNING_MESSAGE);
            this.jtxtBoleta.requestFocus();
        }
        if (!this.jcDetalle.getSelectedItem().toString().trim().isEmpty()) {
        } else {
            validar = false;
            JOptionPane.showMessageDialog(this,
                    "No se a Ingresado Detalle del Pago",
                    "Error",
                    JOptionPane.WARNING_MESSAGE);
            this.jcDetalle.requestFocus();
        }
        if (!this.jcboDoctor.getSelectedItem().toString().equalsIgnoreCase("Selecione Odontologo")) {
        } else {
            validar = false;
            JOptionPane.showMessageDialog(this,
                    "No se a Selecionado un Odontologo",
                    "Error",
                    JOptionPane.WARNING_MESSAGE);
            this.jcboDoctor.requestFocus();
        }

        if (validar) {
            try {
                Guardar(this.jcboDoctor.getSelectedItem().toString());
            } catch (Exception Ex) {
                System.out.print(Ex);
            }
        }
}//GEN-LAST:event_jtxtPagoActionPerformed

    private void jbtExExcelDr1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtExExcelDr1ActionPerformed
        setCursor(new Cursor(Cursor.WAIT_CURSOR));
        if (validaAño(faño.format(jTextField10.getValue()))) {
            int filas = 0;
            String mensaje = "";
            if (!jcbInfo_Odon2.getSelectedItem().toString().equalsIgnoreCase("Selecione Odontologo")) {
                try {
                    Sucursal su = new Sucursal();
                    config cf = new config();
                    if (neg.AñoCerrado(faño.format(this.jTextField10.getValue()), su.getSucursal()) == 12) {
                    } else {
                        //      JOptionPane.showMessageDialog(this, "Este AÑO NO se encuentra CERRADO, la información \n de este informe puede estar INCOMPLETA.", "Aviso", JOptionPane.WARNING_MESSAGE);
                        mensaje = "-**INFORME PARCIAL, NO APTO PARA PAGO**-";
                    }

                    //Se crea el libro Excel
                    WritableWorkbook workbook = Workbook.createWorkbook(new File("C:\\WINDOWS\\Temp\\Odontologo2.xls"));
                    //Se crea una nueva hoja(31caracteres) dentro del libro
                    WritableSheet sheet = workbook.createSheet(jcbInfo_Odon2.getSelectedItem().toString().substring(0, jcbInfo_Odon2.getSelectedItem().toString().length() - 12), 0);
                    WritableSheet sheet1 = workbook.createSheet("Meses", 1);

                    //formato simple para $
                    NumberFormat forma$ = new NumberFormat("$ #,###");
                    WritableCellFormat plata = new WritableCellFormat(forma$);
                    //indicando un patón de formato color, formato de $
                    NumberFormat dp3 = new NumberFormat("$ #,###");
                    WritableCellFormat dp3cell = new WritableCellFormat(dp3);
                    dp3cell.setBackground(Colour.LIGHT_GREEN);
                    dp3cell.setAlignment(Alignment.RIGHT);
                    //formato para titulos......
                    WritableFont formato1 = new WritableFont(WritableFont.TIMES, 9, WritableFont.BOLD, true);
                    formato1.setColour(Colour.BLACK);
                    WritableCellFormat titulo = new WritableCellFormat(formato1);
                    titulo.setAlignment(Alignment.CENTRE);

                    sheet.setColumnView(0, 0);
                    sheet.setColumnView(1, 55);
                    sheet.setColumnView(2, 10);

                    //Imangen en 0,0

                    WritableCellFormat centrado = new WritableCellFormat();
                    centrado.setAlignment(Alignment.CENTRE);

                    sheet.addCell(new jxl.write.Label(2, 1, "FECHA NOMINA", centrado));
                    sheet.addCell(new jxl.write.Label(2, 2, "Inicio " + faño.format(jTextField10.getValue()), centrado));
                    sheet.addCell(new jxl.write.Label(2, 3, "Termino " + faño.format(jTextField10.getValue()), centrado));
                    sheet.addCell(new jxl.write.Label(6, 1, "Fecha Actual", centrado));
                    //fecha actual
                    sheet.addCell(new jxl.write.Label(6, 2, FechaDia + "/" + Mes[Integer.parseInt(FechaMesActual) - 1] + "/" + FechaAño, centrado));

                    WritableFont formato2 = new WritableFont(WritableFont.ARIAL, 16, WritableFont.NO_BOLD, false);
                    formato2.setColour(Colour.BLACK);
                    WritableCellFormat titulo1 = new WritableCellFormat(formato2);
                    titulo1.setAlignment(Alignment.CENTRE);

                    //fucion de celdas
                    sheet.mergeCells(1, 5, 8, 5);//titulo
                    sheet.mergeCells(1, 6, 8, 6);//mensaje
                    sheet.mergeCells(2, 1, 4, 1);
                    sheet.mergeCells(2, 2, 4, 2);
                    sheet.mergeCells(2, 3, 4, 3);
                    sheet.mergeCells(6, 1, 7, 1);
                    sheet.mergeCells(6, 2, 7, 2);
                    sheet.mergeCells(3, 7, 4, 7);//sucursal
                    sheet.mergeCells(5, 7, 6, 7);//usuario

                    sheet.addCell(new jxl.write.Label(1, 5, "PAGOS ODONTOLOGO", titulo1));
                    sheet.addCell(new jxl.write.Label(1, 6, mensaje, titulo));

                    sheet.addCell(new jxl.write.Label(1, 7, "Odontologo: " + this.jcbInfo_Odon2.getSelectedItem().toString()));
                    sheet.addCell(new jxl.write.Label(3, 7, "Sucursal: " + this.jLabelSucursalInformes.getText()));
                    sheet.addCell(new jxl.write.Label(5, 7, "Usuario: " + this.jtxtUser.getText()));

                    sheet.addCell(new jxl.write.Label(1, 10, "PACIENTE", titulo));
                    sheet.addCell(new jxl.write.Label(2, 10, "# PRESUP.", titulo));
                    sheet.addCell(new jxl.write.Label(3, 10, "MONTO PTO.", titulo));
                    sheet.addCell(new jxl.write.Label(4, 10, "LIQUIDACIONES", titulo));
                    sheet.addCell(new jxl.write.Label(5, 10, "#BOLETAS", titulo));
                    sheet.addCell(new jxl.write.Label(6, 10, "LAB.", titulo));
                    sheet.addCell(new jxl.write.Label(7, 10, "BONOS", titulo));

                    ArrayList listarPagosDoctorAño = neg.getBuscarPagoDoctorAÑO(this.jcbInfo_Odon2.getSelectedItem().toString(), faño.format(jTextField10.getValue()));
                    Iterator it = listarPagosDoctorAño.iterator();
                    filas = listarPagosDoctorAño.size();

                    int i = 0;
                    for (i = 0; i < filas; i++) {
                        Pago pag = (Pago) it.next();
                        sheet.addCell(new jxl.write.Label(1, i + 11, pag.getPaciente_rut()));
                        //presupuestos desde 2-2(colum-fila)
                        sheet.addCell(new jxl.write.Number(2, i + 11, pag.getNumero_presupuesto()));
                        //CANTIDAD TOTAL DEL PRESUPUESTO
                        sheet.addCell(new jxl.write.Number(3, i + 11, pag.getValorPrestacion()==0 ? CalcularPresu(pag.getNumero_presupuesto()): pag.getValorPrestacion(), plata));
                        /////////////////////////////////////////////////////////////////////
                        sheet.addCell(new jxl.write.Number(5, i + 11, pag.getPag_num_boleta()));
                        sheet.addCell(new jxl.write.Number(6, i + 11, pag.getLaboratorio(), plata));
                        sheet.addCell(new jxl.write.Number(7, i + 11, pag.getBono(), plata));
                        ////////////////////////////////////////////////////////////////////////////////////////
                        //desde el 2-41
                        jxl.write.Number label = new jxl.write.Number(4, i + 11, pag.getLiquidacion(), dp3cell);
                        WritableCellFeatures features = new WritableCellFeatures();
                        features.setComment(pag.getFecha().substring(8, 10) + "-" + pag.getFecha().substring(5, 7) + "-" + pag.getFecha().substring(0, 4) + "\n " + pag.getDetalle());
                        label.setCellFeatures(features);
                        sheet.addCell(label);
                        ////////////////////////////////////////////////////////////////////////////////////////
                        //(columnas , filas , Dato )
                    }
                    sheet.addCell(new jxl.write.Label(1, i + 16, "TOTAL MESES"));
                    sheet.addCell(new jxl.write.Label(1, i + 17, "TOTAL  BONOS"));
                    sheet.addCell(new jxl.write.Label(1, i + 18, "TOTAL PAGADO"));

                    sheet.addCell(new jxl.write.Formula(2, i + 16, "SUMA(E:E)", dp3cell));
                    sheet.addCell(new jxl.write.Formula(2, i + 17, "SUMA(H:H)", dp3cell));

                    sheet.addCell(new jxl.write.Label(1, 1, "Creado en Valkyrie Versión "+ToolUtil.version));

                    //pagos a la echa..

                    sheet1.addCell(new jxl.write.Label(1, 1, "Valkyrie Versión "+ToolUtil.version));

                    sheet1.addCell(new jxl.write.Label(2, 1, "FECHA NOMINA", centrado));
                    sheet1.addCell(new jxl.write.Label(2, 2, "Inicio " + faño.format(jTextField10.getValue()), centrado));
                    sheet1.addCell(new jxl.write.Label(2, 3, "Termino " + faño.format(jTextField10.getValue()), centrado));
                    sheet1.addCell(new jxl.write.Label(6, 1, "Fecha Actual", centrado));
                    //fecha actual
                    sheet1.addCell(new jxl.write.Label(6, 2, FechaDia + "/" + Mes[Integer.parseInt(FechaMesActual) - 1] + "/" + FechaAño, centrado));
                    sheet1.addCell(new jxl.write.Label(1, 5, "PAGOS ODONTOLOGICOS", titulo1));
                    sheet1.addCell(new jxl.write.Label(2, 7, "A PAGAR: " + this.jcbInfo_Odon2.getSelectedItem().toString()));
                    sheet1.addCell(new jxl.write.Label(2, 8, "Sucursal: " + this.jLabelSucursalInformes.getText()));
                    sheet1.addCell(new jxl.write.Label(5, 8, "Usuario: " + this.jtxtUser.getText()));

                    sheet1.mergeCells(1, 5, 8, 5);
                    sheet1.mergeCells(2, 1, 4, 1);
                    sheet1.mergeCells(2, 2, 4, 2);
                    sheet1.mergeCells(2, 3, 4, 3);
                    sheet1.mergeCells(6, 1, 7, 1);
                    sheet1.mergeCells(6, 2, 7, 2);
                    sheet1.mergeCells(2, 7, 5, 7);

                    sheet1.setColumnView(0, 0);
                    sheet1.setColumnView(1, 10);
                    sheet1.setColumnView(2, 10);
                    sheet1.setColumnView(3, 13);
                    sheet1.setColumnView(4, 10);
                    sheet1.setColumnView(5, 15);
                    sheet1.setColumnView(6, 10);

                    sheet1.addCell(new jxl.write.Label(1, 10, "MESES", titulo));
                    sheet1.addCell(new jxl.write.Label(2, 10, "BONOS", titulo));
                    sheet1.addCell(new jxl.write.Label(3, 10, "SUMA DEL MES", titulo));
                    sheet1.addCell(new jxl.write.Label(4, 10, "PARTICIPACION %", titulo));
                    sheet1.addCell(new jxl.write.Label(5, 10, "RETENCION %", titulo));
                    sheet1.addCell(new jxl.write.Label(6, 10, "LIQUIDACION", titulo));

                    double a5 = 0;
                    double s6 = 0;
                    int me = 0;

                    for (me = 0; me <= 11; me++) {

                        sheet1.addCell(new jxl.write.Label(1, me + 11, Mes[me], titulo));
                        if (!neg.Cerrado(Mes[me], Integer.parseInt(faño.format(jTextField10.getValue())), su.getSucursal())) {


                            Iterator itsu = neg.ListarSucursales().iterator();
                            while (itsu.hasNext()) {
                                Sucursales suc = (Sucursales) itsu.next();

                                if (suc.getSucursales().equalsIgnoreCase("San Antonio") && su.getSucursal().equalsIgnoreCase("1")) {
                                    a5 = Double.parseDouble("" + suc.getParticipacion());
                                    s6 = Double.parseDouble("" + suc.getRetencion());
                                    //              sheet.addCell(new jxl.write.Label(1, (k + i) + 17, "PARTICIPACION " + suc.getParticipacion() + "%"));
                                }
                                if (suc.getSucursales().equalsIgnoreCase("Bandera") && su.getSucursal().equalsIgnoreCase("2")) {
                                    a5 = Double.parseDouble("" + suc.getParticipacion());
                                    s6 = Double.parseDouble("" + suc.getRetencion());
                                    //            sheet.addCell(new jxl.write.Label(1, (k + i) + 17, "PARTICIPACION " + suc.getParticipacion() + "%"));
                                }
                                if (suc.getSucursales().equalsIgnoreCase("Manuel Montt") && su.getSucursal().equalsIgnoreCase("3")) {
                                    a5 = Double.parseDouble("" + suc.getParticipacion());
                                    s6 = Double.parseDouble("" + suc.getRetencion());
                                    //           sheet.addCell(new jxl.write.Label(1, (k + i) + 17, "PARTICIPACION " + suc.getParticipacion() + "%"));
                                }
                                if (suc.getSucursales().equalsIgnoreCase("La Florida") && su.getSucursal().equalsIgnoreCase("5")) {
                                    a5 = Double.parseDouble("" + suc.getParticipacion());
                                    s6 = Double.parseDouble("" + suc.getRetencion());
                                    //           sheet.addCell(new jxl.write.Label(1, (k + i) + 17, "PARTICIPACION " + suc.getParticipacion() + "%"));
                                }
                            }
                        } else {
                            Iterator it8 = neg.MesCerrado(Mes[me], Integer.parseInt(faño.format(jTextField10.getValue())), Integer.parseInt(su.getSucursal())).iterator();
                            while (it8.hasNext()) {
                                CerrarMes cm = (CerrarMes) it8.next();
                                a5 = Double.parseDouble(cm.getPorsentaje());
                                s6 = Double.parseDouble(cm.getRetencion());
                            }
                        }
                        ArrayList listaBuscarPagoGe = neg.getBuscarPagoGe("" + ValidaFecha((me + 1), faño.format(jTextField10.getValue())), su.getSucursal());
                        Iterator it2 = listaBuscarPagoGe.iterator();
                        int filas2 = listaBuscarPagoGe.size();
                        for (int B = 0; B < filas2; B++) {

                            Pago pag = (Pago) it2.next();
                            if (pag.getDoc_rut().equalsIgnoreCase(this.jcbInfo_Odon2.getSelectedItem().toString())) {
                                if (pag.getDoc_rut().equalsIgnoreCase("AYARZA GOENAGA JULIAN (6888148-K)") && cf.getActivaRetencion().equalsIgnoreCase("true")) {
                                    sheet1.addCell(new jxl.write.Number(2, me + 11, pag.getBono(), plata));
                                    sheet1.addCell(new jxl.write.Number(3, me + 11, pag.getLiquidacion(), dp3cell));
                                    sheet1.addCell(new jxl.write.Number(4, me + 11, a5));
                                    sheet1.addCell(new jxl.write.Label(5, me + 11, "No retención"));
                                    sheet1.addCell(new jxl.write.Formula(6, me + 11, "C" + (me + 12) + "+D" + (me + 12) + "*(E" + (me + 12) + "/100)", plata));

                                } else {
                                    sheet1.addCell(new jxl.write.Number(2, me + 11, pag.getBono(), plata));
                                    sheet1.addCell(new jxl.write.Number(3, me + 11, pag.getLiquidacion(), dp3cell));
                                    sheet1.addCell(new jxl.write.Number(4, me + 11, a5));
                                    sheet1.addCell(new jxl.write.Number(5, me + 11, s6));
                                    sheet1.addCell(new jxl.write.Formula(6, me + 11, "(C" + (me + 12) + "+(D" + (me + 12) + "*(E" + (me + 12) + "/100)))-((D" + (me + 12) + "*(E" + (me + 12) + "/100))+C" + (me + 12) + ")*(F" + (me + 12) + "/100)+C" + (me + 12), plata));
                                }
                            }
                        }
                    }

                    sheet1.addCell(new jxl.write.Label(1, me + 12, "SUMA TOTALES", titulo));
                    sheet1.addCell(new jxl.write.Formula(2, me + 12, "SUMA(C12:C23)", dp3cell));
                    sheet1.addCell(new jxl.write.Formula(3, me + 12, "SUMA(D12:D23)", dp3cell));
                    sheet1.addCell(new jxl.write.Formula(6, me + 12, "SUMA(G12:G23)", dp3cell));
                    sheet.addCell(new jxl.write.Formula(2, i + 18, "Meses!G25", dp3cell));

                    workbook.write();
                    workbook.close();

                } catch (IOException ex) {
                    JOptionPane.showMessageDialog(this, "ya tiene el fichero abierto.\n" + ex, "Error", JOptionPane.WARNING_MESSAGE);
                } catch (WriteException ex) {
                    JOptionPane.showMessageDialog(this, "ya tiene el fichero abierto.\n" + ex, "Error", JOptionPane.WARNING_MESSAGE);
                } catch (NumberFormatException ex) {
                    JOptionPane.showMessageDialog(this, "ya tiene el fichero abierto.\n" + ex, "Error", JOptionPane.WARNING_MESSAGE);
                }

                try {

                    if (filas > 0) {
                        Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler  C:\\WINDOWS\\Temp\\Odontologo2.xls");
                    } else {
                        JOptionPane.showMessageDialog(this, "No tiene informacion");
                    }

                } catch (IOException ee) {
                    JOptionPane.showMessageDialog(this, "ERROR.\n" + ee, "Error", JOptionPane.WARNING_MESSAGE);
                }

            } else {

                JOptionPane.showMessageDialog(this,
                        "No se a Selecionado un Odontologo",
                        "Error",
                        JOptionPane.WARNING_MESSAGE);
                this.jcbInfo_Odon2.requestFocus();
            }
        } else {
            JOptionPane.showMessageDialog(this,
                    "Fecha no Corresponde",
                    "Error",
                    JOptionPane.WARNING_MESSAGE);
        }
        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}//GEN-LAST:event_jbtExExcelDr1ActionPerformed

    private void jbtBuscarDoctorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtBuscarDoctorActionPerformed
        if (validaAño(faño.format(jtxtAño.getValue()))) {
            try {
                //         TODO add your handling code here:
                TotalPagado = 0;
                TotalLab = 0;
                TotalRayo = 0;
                ValorPrestacion = 0;
                RutPaciente = 0;
                Bono = 0;

                //BUSCAR EL PRESU EN ACCESS
                ArrayList listaBuscarPagoDoctor = neg.getBuscarPagoDoctor(this.jcboDoctorBuscar.getSelectedItem().toString(), ValidaFecha(this.jcboFecha.getSelectedIndex() + 1, this.jtxtAño.getValue().toString()));
                Iterator it = listaBuscarPagoDoctor.iterator();
                String[] camposa = {"Fecha", "Liquidado", "Laboratorio", "Bono", "Rayos", "Descripcion", "Paciente", "Boleta"};
                DefaultTableModel modela = new DefaultTableModel();
                int filasa = listaBuscarPagoDoctor.size();
                //creo una matriz
                Object[][] datosa = new Object[filasa][8];

                if (0 == filasa) {
                    jTbuscarDoctor.setModel(modela);
                    JOptionPane.showMessageDialog(this,
                            "No hay Datos.",
                            "No Dato",
                            JOptionPane.INFORMATION_MESSAGE);
                }

                for (int i = 0; i < filasa; i++) {
                    Pago pag = (Pago) it.next();

                    jTbuscarDoctor.setVisible(true);
                    Bono += pag.getBono();
                    TotalLab += pag.getLaboratorio();
                    TotalPagado += pag.getLiquidacion();
                    TotalRayo += pag.getRayosDarsalud();
                    for (int f = 0; f < 8; f++) {
                        datosa[i][0] = pag.getFecha().substring(8, 10) + "-" + pag.getFecha().substring(5, 7) + "-" + pag.getFecha().substring(0, 4);
                        //busco los Rut de los DR asociados a la BD Access
                        datosa[i][1] = df.format(pag.getLiquidacion());
                        datosa[i][2] = df.format(pag.getLaboratorio());
                        datosa[i][3] = df.format(pag.getBono());
                        datosa[i][4] = df.format(pag.getRayosDarsalud());
                        datosa[i][5] = pag.getDetalle();
                        datosa[i][6] = pag.getPaciente_rut();
                        datosa[i][7] = pag.getPag_num_boleta() + "(" + pag.getNumero_presupuesto() + ")";
                        //cargar datos en la tabla
                        modela.setDataVector(datosa, camposa);
                        //seteo la jtable con el table model
                        this.jTbuscarDoctor.setModel(modela);
                        this.jTbuscarDoctor.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
                        this.jTbuscarDoctor.setEnabled(false);
                        //cambiamos el ancho de las columnas
                        TableColumn column = new TableColumn();
                        column = this.jTbuscarDoctor.getColumnModel().getColumn(0);
                        column.setPreferredWidth(70);
                        column = this.jTbuscarDoctor.getColumnModel().getColumn(1);
                        column.setPreferredWidth(70);
                        column = this.jTbuscarDoctor.getColumnModel().getColumn(2);
                        column.setPreferredWidth(70);
                        column = this.jTbuscarDoctor.getColumnModel().getColumn(3);
                        column.setPreferredWidth(70);
                        column = this.jTbuscarDoctor.getColumnModel().getColumn(4);
                        column.setPreferredWidth(70);
                        column = this.jTbuscarDoctor.getColumnModel().getColumn(5);
                        column.setPreferredWidth(300);
                        column = this.jTbuscarDoctor.getColumnModel().getColumn(6);
                        column.setPreferredWidth(250);
                    }
                }
                CalculosDr(TotalPagado);
                this.jbtExExcelDr.setEnabled(true);
            } catch (IOException ex) {
                System.out.println(ex);
            }
        } else {
            JOptionPane.showMessageDialog(this,
                    "No hay Datos.",
                    "No Dato",
                    JOptionPane.INFORMATION_MESSAGE);
        }
}//GEN-LAST:event_jbtBuscarDoctorActionPerformed

    private void jcboFechaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcboFechaActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_jcboFechaActionPerformed

    private void jbtExExcelDrActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtExExcelDrActionPerformed

        setCursor(new Cursor(Cursor.WAIT_CURSOR));
        if (validaAño(faño.format(jTextField9.getValue()))) {
            int filas = 0;
            String mensaje = " ";

            if (!this.jcbInfo_Odon1.getSelectedItem().toString().trim().isEmpty() && !jcbInfo_Odon1.getSelectedItem().toString().equalsIgnoreCase("Selecione Odontologo")) {
                try {
                    Sucursal su = new Sucursal();
                    if (!neg.Cerrado(this.jComboBox7.getSelectedItem().toString(), Integer.parseInt(faño.format(jTextField9.getValue())), su.getSucursal())) {
                        mensaje = "-**INFORME PARCIAL, NO APTO PARA PAGO**-";
                    }

                    //Se crea el libro Excel
                    WritableWorkbook workbook = Workbook.createWorkbook(new File("C:\\WINDOWS\\Temp\\Odontologo.xls"));
                    //Se crea una nueva hoja(31caracteres) dentro del libro
                    WritableSheet sheet = workbook.createSheet(jcbInfo_Odon1.getSelectedItem().toString().substring(0, jcbInfo_Odon1.getSelectedItem().toString().length() - 12), 0);

                    //formato simple para $
                    NumberFormat forma$ = new NumberFormat("$ #,###");
                    WritableCellFormat plata = new WritableCellFormat(forma$);
                    //indicando un patón de formato color, formato de $
                    NumberFormat dp3 = new NumberFormat("$ #,###");
                    WritableCellFormat dp3cell = new WritableCellFormat(dp3);
                    dp3cell.setBackground(Colour.LIGHT_GREEN);
                    dp3cell.setAlignment(Alignment.RIGHT);
                    //formato para titulos......
                    WritableFont formato1 = new WritableFont(WritableFont.TIMES, 9, WritableFont.BOLD, true);
                    formato1.setColour(Colour.BLACK);
                    WritableCellFormat titulo = new WritableCellFormat(formato1);
                    titulo.setAlignment(Alignment.CENTRE);

                    sheet.setColumnView(0, 0);
                    sheet.setColumnView(1, 45);
                    sheet.setColumnView(2, 10);
                    sheet.setColumnView(3, 13);
                    sheet.setColumnView(4, 15);
                    sheet.setColumnView(5, 10);
                    sheet.setColumnView(7, 0);
                    sheet.setColumnView(8, 0);

                    WritableCellFormat centrado = new WritableCellFormat();
                    centrado.setAlignment(Alignment.CENTRE);

                    sheet.addCell(new jxl.write.Label(2, 1, "FECHA NOMINA", centrado));
                    sheet.addCell(new jxl.write.Label(2, 2, "Inicio 01/" + this.Mes[jComboBox7.getSelectedIndex()] + "/" + faño.format(jTextField9.getValue()), centrado));

                    sheet.addCell(new jxl.write.Label(2, 3, "Termino "
                            + ValidaFecha(jComboBox7.getSelectedIndex() + 1, faño.format(jTextField9.getValue())).substring(ValidaFecha(
                            jComboBox7.getSelectedIndex() + 1, faño.format(jTextField9.getValue())).length() - 2,
                            ValidaFecha(jComboBox7.getSelectedIndex() + 1, faño.format(jTextField9.getValue())).length()) + "/" + this.Mes[jComboBox7.getSelectedIndex()] + "/" + faño.format(jTextField9.getValue()), centrado));

                    sheet.addCell(new jxl.write.Label(5, 1, "Fecha Actual", centrado));
                    //fecha actual
                    sheet.addCell(new jxl.write.Label(5, 2, FechaDia + "/" + Mes[Integer.parseInt(FechaMesActual) - 1] + "/" + FechaAño, centrado));

                    WritableFont formato2 = new WritableFont(WritableFont.ARIAL, 16, WritableFont.NO_BOLD, false);
                    formato2.setColour(Colour.BLACK);
                    WritableCellFormat titulo1 = new WritableCellFormat(formato2);
                    titulo1.setAlignment(Alignment.CENTRE);

                    //fucion de celdas
                    sheet.mergeCells(1, 5, 8, 5);//titulo
                    sheet.mergeCells(1, 6, 8, 6);//mensaje
                    sheet.mergeCells(2, 1, 4, 1);
                    sheet.mergeCells(2, 2, 4, 2);
                    sheet.mergeCells(2, 3, 4, 3);
                    sheet.mergeCells(3, 8, 4, 8);//sucursal
                    sheet.mergeCells(5, 8, 6, 8);//usuario
                    sheet.mergeCells(5, 1, 6, 1);
                    sheet.mergeCells(5, 2, 6, 2);

                    sheet.addCell(new jxl.write.Label(1, 5, "CARTOLA PAGOS ODONTOLOGICOS", titulo1));
                    sheet.addCell(new jxl.write.Label(1, 6, mensaje, titulo));

                    sheet.addCell(new jxl.write.Label(1, 8, "A PAGAR: " + this.jcbInfo_Odon1.getSelectedItem().toString()));
                    sheet.addCell(new jxl.write.Label(3, 8, "Sucursal: " + this.jLabelSucursalInformes.getText()));
                    sheet.addCell(new jxl.write.Label(5, 8, "Usuario: " + this.jtxtUser.getText()));

                    sheet.addCell(new jxl.write.Label(1, 10, "PACIENTE", titulo));
                    sheet.addCell(new jxl.write.Label(2, 10, "# PRESUP.", titulo));
                    sheet.addCell(new jxl.write.Label(3, 10, "MONTO PTO.", titulo));
                    sheet.addCell(new jxl.write.Label(4, 10, "LIQUIDACIONES", titulo));
                    sheet.addCell(new jxl.write.Label(5, 10, "#BOLETAS", titulo));
                    // sheet.addCell(new jxl.write.Label(6, 10, "BONOS", titulo));
                    sheet.addCell(new jxl.write.Label(7, 10, "RAYOS", titulo));
                    sheet.addCell(new jxl.write.Label(8, 10, "LAB.", titulo));
                    
                    ArrayList listaPagosDoctor = neg.getBuscarPagoDoctor(this.jcbInfo_Odon1.getSelectedItem().toString(), ValidaFecha(this.jComboBox7.getSelectedIndex() + 1, faño.format(this.jTextField9.getValue())));
                    Iterator it = listaPagosDoctor.iterator();
                    filas = listaPagosDoctor.size();
                    int i = 0;

                    for (int ii = 0; ii < filas; ii++) {
                        Pago pag = (Pago) it.next();
                        if (pag.getBono() == 0) {//ocea es un pago..
                            sheet.addCell(new jxl.write.Label(1, i + 11, pag.getPaciente_rut()));
                            //presupuestos desde 2-2(colum-fila)
                            sheet.addCell(new jxl.write.Number(2, i + 11, pag.getNumero_presupuesto()));
                            //CANTIDAD TOTAL DEL PRESUPUESTO
                            sheet.addCell(new jxl.write.Number(3, i + 11, pag.getValorPrestacion()==0 ? CalcularPresu(pag.getNumero_presupuesto()): pag.getValorPrestacion(), plata));
                            /////////////////////////////////////////////////////////////////////
                            sheet.addCell(new jxl.write.Number(5, i + 11, pag.getPag_num_boleta()));
                            // sheet.addCell(new jxl.write.Number(6, i + 11, pag.getBono(), plata));
                            sheet.addCell(new jxl.write.Number(7, i + 11, pag.getRayosDarsalud(), plata));
                            sheet.addCell(new jxl.write.Number(8, i + 11, pag.getLaboratorio(), plata));
                            ////////////////////////////////////////////////////////////////////////////////////////
                            //desde el 2-41
                            jxl.write.Number label = new jxl.write.Number(4, i + 11, pag.getLiquidacion(), dp3cell);
                            WritableCellFeatures features = new WritableCellFeatures();
                            features.setComment(pag.getFecha().substring(8, 10) + "-" + pag.getFecha().substring(5, 7) + "-" + pag.getFecha().substring(0, 4) + "\n " + pag.getDetalle());
                            label.setCellFeatures(features);
                            sheet.addCell(label);
                            ////////////////////////////////////////////////////////////////////////////////////////
                            i++;
                        }
                    }
                    sheet.addCell(new jxl.write.Label(1, i + 13, "BONOS VIAJE", titulo));
                    ArrayList listaBonos = neg.buscaBonos(this.jcbInfo_Odon1.getSelectedItem().toString(), ValidaFecha(this.jComboBox7.getSelectedIndex() + 1, faño.format(jTextField9.getValue())));
                    Iterator it2 = listaBonos.iterator();
                    int contBonos = listaBonos.size();
                    int k = i;
                    int sumaBono = 0;
                    // int contador = 0;
                    for (k = 0; k < contBonos; k++) {
                        Pago pag = (Pago) it2.next();
                        if (pag.getBono() != 0) {
                            sheet.addCell(new jxl.write.Label(1, (k + i) + 14, pag.getPaciente_rut()));
                            ////////////////////////////////////////////////////////////////////////////////////////
                            jxl.write.Number label = new jxl.write.Number(2, (k + i) + 14, pag.getBono(), dp3cell);
                            sumaBono += pag.getBono();
                            WritableCellFeatures features = new WritableCellFeatures();
                            features.setComment(pag.getFecha().substring(8, 10) + "-" + pag.getFecha().substring(5, 7) + "-" + pag.getFecha().substring(0, 4) + "\n " + pag.getDetalle());
                            label.setCellFeatures(features);
                            sheet.addCell(label);
                            ////////////////////////////////////////////////////////////////////////////////////////
                            //  contador++;
                        } else {
                            //  contBonos--;
                            i--;
                        }
                    }
                    sheet.addCell(new jxl.write.Label(1, (k + i) + 16, "TOTAL"));
                    config cf = new config();
                    double a5 = 0;
                    double s6 = 0;
                    if (!neg.Cerrado(this.jComboBox7.getSelectedItem().toString(), Integer.parseInt(faño.format(jTextField9.getValue())), su.getSucursal())) {

                        Iterator itsu = neg.ListarSucursales().iterator();
                        while (itsu.hasNext()) {
                            Sucursales suc = (Sucursales) itsu.next();

                            if (suc.getSucursales().equalsIgnoreCase("San Antonio") && su.getSucursal().equalsIgnoreCase("1")) {
                                a5 = Double.parseDouble("0." + suc.getParticipacion());
                                s6 = Double.parseDouble("0." + suc.getRetencion());
                                sheet.addCell(new jxl.write.Label(1, (k + i) + 17, "PARTICIPACION " + suc.getParticipacion() + "%"));
                            }
                            if (suc.getSucursales().equalsIgnoreCase("Bandera") && su.getSucursal().equalsIgnoreCase("2")) {
                                a5 = Double.parseDouble("0." + suc.getParticipacion());
                                s6 = Double.parseDouble("0." + suc.getRetencion());
                                sheet.addCell(new jxl.write.Label(1, (k + i) + 17, "PARTICIPACION " + suc.getParticipacion() + "%"));
                            }
                            if (suc.getSucursales().equalsIgnoreCase("Manuel Montt") && su.getSucursal().equalsIgnoreCase("3")) {
                                a5 = Double.parseDouble("0." + suc.getParticipacion());
                                s6 = Double.parseDouble("0." + suc.getRetencion());
                                sheet.addCell(new jxl.write.Label(1, (k + i) + 17, "PARTICIPACION " + suc.getParticipacion() + "%"));
                            }
                            if (suc.getSucursales().equalsIgnoreCase("La Florida") && su.getSucursal().equalsIgnoreCase("5")) {
                                a5 = Double.parseDouble("0." + suc.getParticipacion());
                                s6 = Double.parseDouble("0." + suc.getRetencion());
                                sheet.addCell(new jxl.write.Label(1, (k + i) + 17, "PARTICIPACION " + suc.getParticipacion() + "%"));
                            }
                        }
                    } else {
                        Iterator it8 = neg.MesCerrado(this.jComboBox7.getSelectedItem().toString(), Integer.parseInt(faño.format(jTextField9.getValue())), Integer.parseInt(su.getSucursal())).iterator();
                        while (it8.hasNext()) {
                            CerrarMes cm = (CerrarMes) it8.next();
                            a5 = Double.parseDouble("0." + cm.getPorsentaje());
                            s6 = Double.parseDouble("0." + cm.getRetencion());
                            sheet.addCell(new jxl.write.Label(1, (k + i) + 17, "PARTICIPACION " + cm.getPorsentaje() + "%"));
                        }
                    }
                    sheet.addCell(new jxl.write.Label(1, (k + i) + 18, "TOTAL BONO"));
                    sheet.addCell(new jxl.write.Label(1, (k + i) + 19, "SIN RETENCION "));
                    sheet.addCell(new jxl.write.Label(1, (k + i) + 20, "RETENCION " + (s6 * 100) + "% "));
                    sheet.addCell(new jxl.write.Label(1, (k + i) + 21, "TOTAL A PAGAR"));
                    //otras formulas ....
                    sheet.addCell(new Formula(2, (k + i) + 16, "SUMA(E:E)", dp3cell));
                    sheet.addCell(new Formula(2, (k + i) + 17, "C" + ((k + i) + 17) + "*" + a5, dp3cell));
//                    System.out.println("" + filas);
//                    System.out.println("" + contBonos);
                    //sheet.addCell(new Formula(2, (k + i) + 18, "SUMA(C" + (((filas - contBonos) + 15) + contBonos) + ":C" + ((filas - contBonos) + 17) + ")", dp3cell));//suma de BONOS
                    sheet.addCell(new jxl.write.Number(2, (k + i) + 18, sumaBono, dp3cell));
                    if (this.jcbInfo_Odon1.getSelectedItem().toString().equalsIgnoreCase("AYARZA GOENAGA JULIAN (6888148-K)") && cf.getActivaRetencion().equalsIgnoreCase("true")) {

                        sheet.addCell(new Formula(2, (k + i) + 19, "C" + ((k + i) + 18) + "+C" + ((k + i) + 19), dp3cell));
                        sheet.addCell(new jxl.write.Label(2, (k + i) + 20, "No retención"));
                        sheet.addCell(new Formula(2, (k + i) + 21, "(C" + ((k + i) + 18) + "+C" + ((k + i) + 19) + ")", dp3cell));
                    } else {

                        sheet.addCell(new Formula(2, (k + i) + 19, "C" + ((k + i) + 18) + "+C" + ((k + i) + 19), dp3cell));
                        sheet.addCell(new Formula(2, (k + i) + 20, "(C" + ((k + i) + 18) + "+C" + ((k + i) + 19) + ")*" + s6, dp3cell));
                        sheet.addCell(new Formula(2, (k + i) + 21, "(C" + ((k + i) + 18) + "+C" + ((k + i) + 19) + ")-C" + ((k + i) + 21), dp3cell));
                    }

                    sheet.addCell(new jxl.write.Label(1, 1, "Creado en Valkyrie Versión "+ToolUtil.version));
                    workbook.write();
                    workbook.close();

                } catch (Exception ex) {
                    JOptionPane.showMessageDialog(this, "ya tiene el fichero abierto.\n" + ex, "Error", JOptionPane.WARNING_MESSAGE);
                }

                try {
                    if (filas > 0) {
                        Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler  C:\\WINDOWS\\Temp\\Odontologo.xls");
                    } else {
                        JOptionPane.showMessageDialog(this, "No tiene informacion");
                    }
                } catch (IOException ee) {
                    JOptionPane.showMessageDialog(this, "ERROR.\n" + ee, "Error", JOptionPane.WARNING_MESSAGE);
                }

            } else {

                JOptionPane.showMessageDialog(this,
                        "No se a Selecionado un Odontologo",
                        "Error",
                        JOptionPane.WARNING_MESSAGE);
                this.jcbInfo_Odon1.requestFocus();
            }
        } else {
            JOptionPane.showMessageDialog(this,
                    "Fecha no Corresponde",
                    "Error",
                    JOptionPane.WARNING_MESSAGE);
        }
        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}//GEN-LAST:event_jbtExExcelDrActionPerformed

    private void jcboFechaIngresoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcboFechaIngresoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jcboFechaIngresoActionPerformed

    private void jbtExExcelDr2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtExExcelDr2ActionPerformed
    }//GEN-LAST:event_jbtExExcelDr2ActionPerformed

    private void jbtSanAntonioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtSanAntonioActionPerformed
        jtxtPresupuesto.setText("");
        jtxtValorPresupuesto.setText("");
        jtOracle.setVisible(false);
        jbtGuardar.setEnabled(false);
        jtxtPago.setEnabled(false);
        jcbLaboratorio.setEditable(false);
        jtxtRayos.setEditable(false);
        jcboDoctor.setSelectedIndex(0);
        jtxtPaciente.setText("");
        jcboDoctor.setSelectedIndex(0);
        jcDetalle.removeAllItems();
        jcDetalle.addItem("Detalle del Pago");

        // instancio objetos de escritura
        FileWriter fichero = null;
        PrintWriter pw = null;
        try {
            // asigno nombre de fichero, mantengo la nomenclatura
            fichero = new FileWriter("C:\\WINDOWS\\system32\\xmlj.ini");
            // asigno PrintWriter a fichero
            pw = new PrintWriter(fichero);

            // escribo los parametros
            pw.println("[Sucursales]");

            pw.println("Sucursal = 1");
            pw.println("CambioSucursal = true");
            pw.println("funcionar = wizard");

            // vuelco la memoria al disco duro
            pw.flush(); // cierro los canales de escritura
            fichero.close();
            pw.close();
        } catch (Exception EX) {
            System.out.println("EROOR!!!!!" + EX);
        }
        // end Guardar
        ValidaSucursal();
    }//GEN-LAST:event_jbtSanAntonioActionPerformed

    private void jbtBanderaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtBanderaActionPerformed
        jtxtPresupuesto.setText("");
        jtxtValorPresupuesto.setText("");
        jtOracle.setVisible(false);
        jbtGuardar.setEnabled(false);
        jtxtPago.setEnabled(false);
        jcbLaboratorio.setEditable(false);
        jtxtRayos.setEditable(false);
        jcboDoctor.setSelectedIndex(0);
        jtxtPaciente.setText("");
        jcboDoctor.setSelectedIndex(0);
        jcDetalle.removeAllItems();
        jcDetalle.addItem("Detalle del Pago");

        FileWriter fichero = null;
        PrintWriter pw = null;
        try {
            // asigno nombre de fichero, mantengo la nomenclatura
            fichero = new FileWriter("C:\\WINDOWS\\system32\\xmlj.ini");
            // asigno PrintWriter a fichero
            pw = new PrintWriter(fichero);

            // escribo los parametros
            pw.println("[Sucursales]");

            pw.println("Sucursal = 2");
            pw.println("CambioSucursal = true");
            pw.println("funcionar = wizard");

            // vuelco la memoria al disco duro
            pw.flush(); // cierro los canales de escritura
            fichero.close();
            pw.close();
        } catch (Exception EX) {
            System.out.println("EROOR!!!!!" + EX);
        }
        ValidaSucursal();
    }//GEN-LAST:event_jbtBanderaActionPerformed

    private void jbtMonttActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtMonttActionPerformed
        // TODO add your handling code here:

        jtxtPresupuesto.setText("");
        jtxtValorPresupuesto.setText("");
        jtOracle.setVisible(false);
        jbtGuardar.setEnabled(false);
        jtxtPago.setEnabled(false);
        jcbLaboratorio.setEditable(false);
        jtxtRayos.setEditable(false);
        jcboDoctor.setSelectedIndex(0);
        jtxtPaciente.setText("");
        jcboDoctor.setSelectedIndex(0);
        jcDetalle.removeAllItems();
        jcDetalle.addItem("Detalle del Pago");

        FileWriter fichero = null;
        PrintWriter pw = null;
        try {
            // asigno nombre de fichero, mantengo la nomenclatura
            fichero = new FileWriter("C:\\WINDOWS\\system32\\xmlj.ini");
            // asigno PrintWriter a fichero
            pw = new PrintWriter(fichero);

            // escribo los parametros
            pw.println("[Sucursales]");

            pw.println("Sucursal = 3");
            pw.println("CambioSucursal = true");
            pw.println("funcionar = wizard");

            // vuelco la memoria al disco duro
            pw.flush(); // cierro los canales de escritura
            fichero.close();
            pw.close();
        } catch (Exception EX) {
            System.out.println("EROOR!!!!!" + EX);
        }
        ValidaSucursal();
    }//GEN-LAST:event_jbtMonttActionPerformed

    private void jBtLoginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtLoginActionPerformed
        // TODO add your handling code here:
        privilegios();

    }//GEN-LAST:event_jBtLoginActionPerformed

    private void jbtConfigActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtConfigActionPerformed
        // TODO add your handling code here:
        try {
            Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler  C:\\WINDOWS\\config.ini");
        } catch (IOException ee) {
            JOptionPane.showMessageDialog(this, "ERROR.\n" + ee,
                    "Error", JOptionPane.WARNING_MESSAGE);
        }
    }//GEN-LAST:event_jbtConfigActionPerformed

    private void jtxtPassActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtxtPassActionPerformed
        privilegios();
    }//GEN-LAST:event_jtxtPassActionPerformed

    private void jTextField6KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField6KeyTyped
        // TODO add your handling code here:
        char letra = evt.getKeyChar();
        if (letra < '0' || letra > '9') {
            evt.consume();
        } else {
            if (this.jTextField6.getText().trim().length() > 6) {
                evt.consume();
            }
        }
    }//GEN-LAST:event_jTextField6KeyTyped

    private void jbtGuardarBonoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtGuardarBonoActionPerformed
        try {
            Sucursal su = new Sucursal();
            if (neg.Cerrado(this.jComboBox4.getSelectedItem().toString(), Integer.parseInt(FechaAño), su.getSucursal())) {
                JOptionPane.showMessageDialog(this,
                        "Este Mes ya se encuentra Cerrado",
                        "Error",
                        JOptionPane.WARNING_MESSAGE);
            } else {
                if (!this.jComboBox5.getSelectedItem().toString().trim().isEmpty() && !jComboBox5.getSelectedItem().toString().equalsIgnoreCase("Selecione Odontologo")) {


                    if (!this.jTextField6.getText().isEmpty() && !jComboBox1.getSelectedItem().toString().isEmpty() && !jComboBox5.getSelectedItem().toString().isEmpty()) {

                        int opcion = 0;
                        opcion = JOptionPane.showConfirmDialog(this,
                                "¿Desea Guardar este Bono?",
                                "Confirmacion",
                                JOptionPane.YES_NO_OPTION,
                                JOptionPane.INFORMATION_MESSAGE);
                        if (opcion == JOptionPane.YES_OPTION) {
                            Pago pag = new Pago();
                            pag.setNumero_presupuesto(1);
                            pag.setDoc_rut(this.jComboBox5.getSelectedItem().toString());
                            pag.setPaciente_rut("Bono DarSalud");
                            pag.setPag_num_boleta(1);
                            pag.setLiquidacion(0);
                            pag.setLaboratorio(0);
                            pag.setBono(Integer.parseInt(this.jTextField6.getText()));
                            //seteo fecha desde el equipo. .dia / mes / año
//                    Date fechaActual = new Date();
//                    SimpleDateFormat formato = new SimpleDateFormat("yyyyMMdd");
//                    String FechaAño = formato.format(fechaActual).substring(0, 4);

                            pag.setGuardadoEl(FechaDia + "/" + FechaMesActual + "/" + FechaAño);
                            int mm = this.jComboBox4.getSelectedIndex() + 1;
                            String FechaMes = "" + mm;
                            for (int num = 1; num <= 9; num++) {
                                if (mm == num) {
                                    //agrego un 0 si es mes es menor a 9
                                    FechaMes = "0" + mm;
                                }
                            }
                            pag.setRayosDarsalud(0);
                            pag.setFecha(FechaDia + "/" + FechaMes + "/" + FechaAño);
                            pag.setDetalle(this.jComboBox1.getSelectedItem().toString());
                            pag.setCOD_SUCURSAL(su.getSucursal());
                            pag.setIngresoPor(this.jtxtUser.getText());
                            NegocioInsert ni = new NegocioInsert();

                            ni.agregarPago(pag);
                            //mostrar abonos ingresados,

                            this.jComboBox5.setSelectedIndex(0);
                            this.jTextField6.setText("");

                        }
                    } else {
                        JOptionPane.showMessageDialog(this, " Falta Informacion ", "Error", JOptionPane.WARNING_MESSAGE);
                    }
                } else {

                    JOptionPane.showMessageDialog(this,
                            "No se a Selecionado un Odontologo",
                            "Error",
                            JOptionPane.WARNING_MESSAGE);
                    this.jcboDoctor.requestFocus();
                }
            }
        } catch (IOException ex) {
            Logger.getLogger(GUI1.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jbtGuardarBonoActionPerformed

    private void jbtVerBonoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtVerBonoActionPerformed
        VerBono();
    }//GEN-LAST:event_jbtVerBonoActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // TODO add your handling code here:
        if (this.jPasswordField1.getText().equalsIgnoreCase("Wizard")) {
            FileWriter fichero = null;
            PrintWriter pw = null;
            try {
                // asigno nombre de fichero, mantengo la nomenclatura
                fichero = new FileWriter("C:\\WINDOWS\\system32\\xmlj.ini");
                // asigno PrintWriter a fichero
                pw = new PrintWriter(fichero);

                // escribo los parametros
                pw.println("[Sucursales]");

                pw.println("porsentaje = 50");
                pw.println("retencion = 10");
                pw.println("Sucursal = 2");
                pw.println("CambioSucursal = true");
                pw.println("funcionar = wizard");

                // vuelco la memoria al disco duro
                pw.flush(); // cierro los canales de escritura
                fichero.close();
                pw.close();
            } catch (Exception EX) {
                System.out.println("EROOR!!!!!" + EX);
            }
            ValidaSucursal();
            System.exit(0);
        } else {
            JOptionPane.showMessageDialog(this,
                    "Contraseña no Valida",
                    "Activacion",
                    JOptionPane.WARNING_MESSAGE);

        }
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // TODO add your handling code here:
        System.exit(0);
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jtxtPagoFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jtxtPagoFocusGained
        // TODO add your handling code here:
        jtxtPago.setText("");
    }//GEN-LAST:event_jtxtPagoFocusGained

    private void jtxtValorPresupuestoFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jtxtValorPresupuestoFocusGained
        // TODO add your handling code here:
    }//GEN-LAST:event_jtxtValorPresupuestoFocusGained

    private void jtbActivarMesesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtbActivarMesesActionPerformed
        // TODO add your handling code here:
        ActivarMes.setVisible(true);
        ActivarMes.setAlwaysOnTop(true);
        ActivarMes.setLocation(400, 240);
        ActivarMes.pack();
    }//GEN-LAST:event_jtbActivarMesesActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        // TODO add your handling code here:
        if (validaAño(faño.format(jSpinner1.getValue()))) {
            try {
                Sucursal su = new Sucursal();
                if (jComboBox6.getSelectedItem().toString().isEmpty()) {
                    JOptionPane.showMessageDialog(this.ActivarMes,
                            "Seleccione un mes",
                            "Aviso",
                            JOptionPane.INFORMATION_MESSAGE);
                } else {
                    if (jSpinner1.getValue().toString().isEmpty()) {
                        JOptionPane.showMessageDialog(this.ActivarMes,
                                "Digite el Año",
                                "Aviso",
                                JOptionPane.INFORMATION_MESSAGE);
                    } else {
                        try {
                            if ((jComboBox6.getSelectedIndex() + 1) == neg.AñoCerrado(faño.format(jSpinner1.getValue()), su.getSucursal())) {

                                int opcion = 0;
                                opcion = JOptionPane.showConfirmDialog(this.ActivarMes,
                                        "¿ESTA SEGURO QUE DESEA ACTIVAR ESTE MES?", "Confirmacion",
                                        JOptionPane.YES_NO_OPTION,
                                        JOptionPane.INFORMATION_MESSAGE);
                                if (opcion == JOptionPane.YES_OPTION) {


                                    //ACTUALIZAR EL REGISTRO DE TA TABLA..
                                    NegocioInsert ni = new NegocioInsert();

                                    ni.EliminiarCierreMes(jComboBox6.getSelectedItem().toString(), faño.format(jSpinner1.getValue()), su.getSucursal());
                                    JOptionPane.showMessageDialog(this.ActivarMes,
                                            "Mes " + jComboBox6.getSelectedItem().toString() + " activo",
                                            "Aviso",
                                            JOptionPane.INFORMATION_MESSAGE);
                                    ActivarMes.setVisible(false);
                                }
                            } else {
                                JOptionPane.showMessageDialog(this.ActivarMes,
                                        "Los meses se desbloquean secuencialmente "
                                        + "\n \n Ultimo mes cerrado "
                                        + Mes[neg.AñoCerrado(faño.format(this.jSpinner1.getValue()), su.getSucursal()) - 1].toUpperCase(),
                                        "Aviso",
                                        JOptionPane.INFORMATION_MESSAGE);
                            }
                        } catch (Exception es) {
                            JOptionPane.showMessageDialog(this.ActivarMes,
                                    "No existe ningun mes para abrir", "Aviso",
                                    JOptionPane.INFORMATION_MESSAGE);
                        }
                    }
                }
            } catch (IOException ex) {
                Logger.getLogger(GUI1.class.getName()).log(Level.SEVERE, null, ex);
            }
        } else {
            JOptionPane.showMessageDialog(this.ActivarMes,
                    "Fecha no Corresponde",
                    "Error",
                    JOptionPane.WARNING_MESSAGE);
        }
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jcDetalleItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jcDetalleItemStateChanged
        // TODO add your handling code here:
        try {
            for (int t = 0; t <= nomproce.size() - 1; t++) {
                if (this.jcDetalle.getSelectedItem().toString().equalsIgnoreCase("" + nomproce.get(t))) {
                    this.jtxtPago.setText("" + canti.get(t));
                }
            }
            if (this.jcDetalle.getSelectedItem().toString().equalsIgnoreCase("Por el Total del Presupuesto.")) {
                String valorString = "" + ValorPrestacion;
                this.jtxtPago.setText("" + valorString.substring(0, valorString.length() - 1) + "0");
            }
        } catch (Exception es) {
        }
    }//GEN-LAST:event_jcDetalleItemStateChanged

    private void jbtExExcelDr3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtExExcelDr3ActionPerformed
        setCursor(new Cursor(Cursor.WAIT_CURSOR));
        if (validaAño(faño.format(jTextField12.getValue()))) {
            try {
                String mensaje = " ";
                boolean parcial = false;
                config cf = new config();
                double a5 = 0;
                double s6 = 0;

                if (!neg.Cerrado(this.jComboBox9.getSelectedItem().toString(), Integer.parseInt(faño.format(jTextField12.getValue())), "1")) {
                    mensaje = "-**INFORME PARCIAL, NO APTO PARA PAGO**-";
                    parcial = true;
                    Iterator itsu = neg.ListarSucursales().iterator();
                    while (itsu.hasNext()) {
                        Sucursales suc = (Sucursales) itsu.next();

                        if (suc.getSucursales().equalsIgnoreCase("San Antonio")) {
                            a5 = Double.parseDouble("0." + suc.getParticipacion());
                            s6 = Double.parseDouble("0." + suc.getRetencion());
                        }

                    }
                } else {
                    Iterator it8 = neg.MesCerrado(this.jComboBox9.getSelectedItem().toString(), Integer.parseInt(faño.format(jTextField12.getValue())), 1).iterator();
                    while (it8.hasNext()) {
                        CerrarMes cm = (CerrarMes) it8.next();
                        a5 = Double.parseDouble("0." + cm.getPorsentaje());
                        s6 = Double.parseDouble("0." + cm.getRetencion());
                    }
                }

                try {
                    //Se crea el libro Excel
                    WritableWorkbook workbook = Workbook.createWorkbook(new File("C:\\WINDOWS\\Temp\\Pagos del Mes " + jComboBox9.getSelectedItem().toString() + " Año " + faño.format(jTextField12.getValue()) + ".xls"));
                    //SAN ANTONIO

                    WritableSheet sheet0 = workbook.createSheet("San Antonio", 0);

                    NumberFormat forma$ = new NumberFormat("$ #,###");
                    WritableCellFormat plata = new WritableCellFormat(forma$);

                    WritableFont formato1 = new WritableFont(WritableFont.TIMES, 15, WritableFont.BOLD, true);
                    formato1.setColour(Colour.BLACK);
                    WritableCellFormat titulo = new WritableCellFormat(formato1);
                    titulo.setAlignment(Alignment.CENTRE);


                    WritableFont formato2 = new WritableFont(WritableFont.ARIAL, 11, WritableFont.BOLD, false);
                    formato2.setColour(Colour.BLACK);
                    WritableCellFormat titulo2 = new WritableCellFormat(formato2);
                    titulo2.setAlignment(Alignment.CENTRE);

                    WritableFont formato3 = new WritableFont(WritableFont.TIMES, 9, WritableFont.BOLD, true);
                    formato3.setColour(Colour.BLACK);
                    WritableCellFormat titulo3 = new WritableCellFormat(formato3);
                    titulo3.setAlignment(Alignment.CENTRE);


                    sheet0.getSettings().setProtected(true);
                    CellView cv = new CellView();
                    cv.setAutosize(true);
                    for (int cl = 1; cl <= 6; cl++) {
                        sheet0.setColumnView(cl, cv);
                        sheet0.setColumnView(cl, cv);
                    }
                    sheet0.mergeCells(1, 4, 8, 4);
                    sheet0.mergeCells(1, 5, 8, 5);

                    sheet0.addCell(new jxl.write.Label(1, 4, "DENTALES SAN ANTONIO " + this.jComboBox9.getSelectedItem().toString(), titulo));
                    sheet0.addCell(new jxl.write.Label(1, 5, mensaje, titulo3));

                    sheet0.addCell(new jxl.write.Label(1, 7, "Odontologo", titulo2));
                    sheet0.addCell(new jxl.write.Label(2, 7, "Ingreso", titulo2));
                    sheet0.addCell(new jxl.write.Label(3, 7, "Participación", titulo2));
                    sheet0.addCell(new jxl.write.Label(4, 7, "Bono", titulo2));
                    sheet0.addCell(new jxl.write.Label(5, 7, "Retención", titulo2));
                    sheet0.addCell(new jxl.write.Label(6, 7, "Total", titulo2));
                    
                    ArrayList listaBuscarPagoGe =neg.getBuscarPagoGe("" + ValidaFecha(this.jComboBox9.getSelectedIndex() + 1, faño.format(jTextField12.getValue())), "1") ;
                    Iterator it = listaBuscarPagoGe.iterator();

                    int filas = listaBuscarPagoGe.size();
                    int s = 0;
                    int rayosS = 0;
                    int labS = 0;
                    for (s = 0; s < filas; s++) {

                        Pago pag = (Pago) it.next();

                        sheet0.addCell(new jxl.write.Label(1, s + 8, pag.getDoc_rut()));
                        sheet0.addCell(new jxl.write.Number(2, s + 8, pag.getLiquidacion(), plata));
                        sheet0.addCell(new jxl.write.Formula(3, s + 8, "C" + (9 + s) + "*" + a5, plata));
                        sheet0.addCell(new jxl.write.Number(4, s + 8, pag.getBono(), plata));
                        sheet0.addCell(new jxl.write.Formula(5, s + 8, "(D" + (s + 9) + "+E" + (s + 9) + ")*" + s6, plata));
                        sheet0.addCell(new jxl.write.Formula(6, s + 8, "(E" + (9 + s) + "+D" + (9 + s) + ")-F" + (9 + s), plata));

                        rayosS += pag.getRayosDarsalud();
                        labS += pag.getLaboratorio();
                    }

                    sheet0.addCell(new jxl.write.Formula(2, s + 9, "SUMA(C9:C" + (s + 8) + " )", plata));
                    sheet0.addCell(new jxl.write.Formula(3, s + 9, "SUMA(D9:D" + (s + 8) + " )", plata));
                    sheet0.addCell(new jxl.write.Formula(4, s + 9, "SUMA(E9:E" + (s + 8) + " )", plata));
                    sheet0.addCell(new jxl.write.Formula(5, s + 9, "SUMA(F9:F" + (s + 8) + " )", plata));
                    sheet0.addCell(new jxl.write.Formula(6, s + 9, "SUMA(G9:G" + (s + 8) + " )", plata));

                    sheet0.addCell(new jxl.write.Label(1, s + 15, "Total Radiografías ", titulo2));
                    sheet0.addCell(new jxl.write.Number(2, s + 15, rayosS, plata));
                    sheet0.addCell(new jxl.write.Label(1, s + 16, "Total Laboratorio ", titulo2));
                    sheet0.addCell(new jxl.write.Number(2, s + 16, labS, plata));


                    mensaje = "";
                    //MANUEL MONTT
                    if (!neg.Cerrado(this.jComboBox9.getSelectedItem().toString(), Integer.parseInt(faño.format(jTextField12.getValue())), "3")) {
                        //         JOptionPane.showMessageDialog(this, "Este Mes NO se encuentra CERRADO, la información \n de este informe puede estar INCOMPLETA.", "Aviso Manuel Montt", JOptionPane.WARNING_MESSAGE);
                        mensaje = "-**INFORME PARCIAL, NO APTO PARA PAGO**-";
                        parcial = true;

                        Iterator itsu = neg.ListarSucursales().iterator();
                        while (itsu.hasNext()) {
                            Sucursales suc = (Sucursales) itsu.next();

                            if (suc.getSucursales().equalsIgnoreCase("Manuel Montt")) {
                                a5 = Double.parseDouble("0." + suc.getParticipacion());
                                s6 = Double.parseDouble("0." + suc.getRetencion());
                            }
                        }
                    } else {
                        Iterator it8 = neg.MesCerrado(this.jComboBox9.getSelectedItem().toString(), Integer.parseInt(faño.format(jTextField12.getValue())), 3).iterator();
                        while (it8.hasNext()) {
                            CerrarMes cm = (CerrarMes) it8.next();
                            a5 = Double.parseDouble("0." + cm.getPorsentaje());
                            s6 = Double.parseDouble("0." + cm.getRetencion());
                        }
                    }

                    WritableSheet sheet1 = workbook.createSheet("Manuel Montt", 1);

                    sheet1.getSettings().setProtected(true);
                    for (int cl = 1; cl <= 6; cl++) {
                        sheet1.setColumnView(cl, cv);
                        sheet1.setColumnView(cl, cv);
                    }
                    sheet1.mergeCells(1, 4, 8, 4);
                    sheet1.mergeCells(1, 5, 8, 5);

                    sheet1.addCell(new jxl.write.Label(1, 4, "DENTALES Manuel Montt " + this.jComboBox9.getSelectedItem().toString(), titulo));
                    sheet1.addCell(new jxl.write.Label(1, 5, mensaje, titulo3));

                    sheet1.addCell(new jxl.write.Label(1, 7, "Odontologo", titulo2));
                    sheet1.addCell(new jxl.write.Label(2, 7, "Ingreso", titulo2));
                    sheet1.addCell(new jxl.write.Label(3, 7, "Participación", titulo2));
                    sheet1.addCell(new jxl.write.Label(4, 7, "Bono", titulo2));
                    sheet1.addCell(new jxl.write.Label(5, 7, "Retención", titulo2));
                    sheet1.addCell(new jxl.write.Label(6, 7, "Total", titulo2));
                    
                    listaBuscarPagoGe = neg.getBuscarPagoGe("" + ValidaFecha(this.jComboBox9.getSelectedIndex() + 1, faño.format(jTextField12.getValue())), "3");
                    Iterator it1 = listaBuscarPagoGe.iterator();
                    int filas1 = listaBuscarPagoGe.size();
                    int M = 0;
                    int rayosM = 0;
                    int labM = 0;
                    for (M = 0; M < filas1; M++) {

                        Pago pag = (Pago) it1.next();

                        sheet1.addCell(new jxl.write.Label(1, M + 8, pag.getDoc_rut()));
                        sheet1.addCell(new jxl.write.Number(2, M + 8, pag.getLiquidacion(), plata));
                        sheet1.addCell(new jxl.write.Formula(3, M + 8, "C" + (9 + M) + "*" + a5, plata));
                        sheet1.addCell(new jxl.write.Number(4, M + 8, pag.getBono(), plata));
                        sheet1.addCell(new jxl.write.Formula(5, M + 8, "(D" + (M + 9) + "+E" + (M + 9) + ")*" + s6, plata));
                        sheet1.addCell(new jxl.write.Formula(6, M + 8, "(E" + (9 + M) + "+D" + (9 + M) + ")-F" + (9 + M), plata));

                        rayosM += pag.getRayosDarsalud();
                        labM += pag.getLaboratorio();
                    }

                    sheet1.addCell(new jxl.write.Formula(2, M + 9, "SUMA(C" + (M + 9) + ":C9)", plata));
                    sheet1.addCell(new jxl.write.Formula(3, M + 9, "SUMA(D" + (M + 9) + ":D9)", plata));
                    sheet1.addCell(new jxl.write.Formula(4, M + 9, "SUMA(E" + (M + 9) + ":E9)", plata));
                    sheet1.addCell(new jxl.write.Formula(5, M + 9, "SUMA(F" + (M + 9) + ":F9)", plata));
                    sheet1.addCell(new jxl.write.Formula(6, M + 9, "SUMA(G" + (M + 9) + ":G9)", plata));

                    sheet1.addCell(new jxl.write.Label(1, M + 15, "Total Radiografías ", titulo2));
                    sheet1.addCell(new jxl.write.Number(2, M + 15, rayosM, plata));
                    sheet1.addCell(new jxl.write.Label(1, M + 16, "Total Laboratorio ", titulo2));
                    sheet1.addCell(new jxl.write.Number(2, M + 16, labM, plata));

                    mensaje = "";
                    //BANDERA
                    if (!neg.Cerrado(this.jComboBox9.getSelectedItem().toString(), Integer.parseInt(faño.format(jTextField12.getValue())), "2")) {
                        //          JOptionPane.showMessageDialog(this, "Este Mes NO se encuentra CERRADO, la información \n de este informe puede estar INCOMPLETA.", "Aviso Bandera", JOptionPane.WARNING_MESSAGE);
                        mensaje = "-**INFORME PARCIAL, NO APTO PARA PAGO**-";
                        parcial = true;
                        Iterator itsu = neg.ListarSucursales().iterator();
                        while (itsu.hasNext()) {
                            Sucursales suc = (Sucursales) itsu.next();

                            if (suc.getSucursales().equalsIgnoreCase("Bandera")) {
                                a5 = Double.parseDouble("0." + suc.getParticipacion());
                                s6 = Double.parseDouble("0." + suc.getRetencion());
                            }

                        }
                    } else {
                        Iterator it8 = neg.MesCerrado(this.jComboBox9.getSelectedItem().toString(), Integer.parseInt(faño.format(jTextField12.getValue())), 2).iterator();
                        while (it8.hasNext()) {
                            CerrarMes cm = (CerrarMes) it8.next();
                            a5 = Double.parseDouble("0." + cm.getPorsentaje());
                            s6 = Double.parseDouble("0." + cm.getRetencion());
                        }
                    }

                    WritableSheet sheet2 = workbook.createSheet("Bandera", 2);
                    sheet2.mergeCells(1, 4, 8, 4);
                    sheet2.mergeCells(1, 5, 8, 5);
                    sheet2.addCell(new jxl.write.Label(1, 4, "DENTALES   Bandera " + this.jComboBox9.getSelectedItem().toString(), titulo));
                    sheet2.addCell(new jxl.write.Label(1, 5, mensaje, titulo3));

                    sheet2.getSettings().setProtected(true);
                    for (int cl = 1; cl <= 6; cl++) {
                        sheet2.setColumnView(cl, cv);
                        sheet2.setColumnView(cl, cv);
                    }
                    sheet2.addCell(new jxl.write.Label(1, 7, "Odontologo", titulo2));
                    sheet2.addCell(new jxl.write.Label(2, 7, "Ingreso", titulo2));
                    sheet2.addCell(new jxl.write.Label(3, 7, "Participación", titulo2));
                    sheet2.addCell(new jxl.write.Label(4, 7, "Bono", titulo2));
                    sheet2.addCell(new jxl.write.Label(5, 7, "Retención", titulo2));
                    sheet2.addCell(new jxl.write.Label(6, 7, "Total", titulo2));
                    
                    listaBuscarPagoGe = neg.getBuscarPagoGe("" + ValidaFecha(this.jComboBox9.getSelectedIndex() + 1, faño.format(jTextField12.getValue())), "2");
                    Iterator it2 = listaBuscarPagoGe.iterator();
                    int filas2 = listaBuscarPagoGe.size();
                    int B = 0;
                    int rayosB = 0;
                    int labB = 0;
                    for (B = 0; B < filas2; B++) {

                        Pago pag = (Pago) it2.next();

                        sheet2.addCell(new jxl.write.Label(1, B + 8, pag.getDoc_rut()));
                        sheet2.addCell(new jxl.write.Number(2, B + 8, pag.getLiquidacion(), plata));
                        sheet2.addCell(new jxl.write.Formula(3, B + 8, "C" + (9 + B) + "*" + a5, plata));
                        sheet2.addCell(new jxl.write.Number(4, B + 8, pag.getBono(), plata));
                        sheet2.addCell(new jxl.write.Formula(5, B + 8, "(D" + (B + 9) + "+E" + (B + 9) + ")*" + s6, plata));
                        sheet2.addCell(new jxl.write.Formula(6, B + 8, "(E" + (9 + B) + "+D" + (9 + B) + ")-F" + (9 + B), plata));

                        rayosB += pag.getRayosDarsalud();
                        labB += pag.getLaboratorio();
                        if (pag.getDoc_rut().equalsIgnoreCase("AYARZA GOENAGA JULIAN (6888148-K)") && cf.getActivaRetencion().equalsIgnoreCase("true")) {

                            jxl.write.Number label = new jxl.write.Number(5, B + 8, 0, plata);
                            WritableCellFeatures features = new WritableCellFeatures();
                            features.setComment("No Retencion");
                            label.setCellFeatures(features);
                            sheet2.addCell(label);

                        }
                    }

                    sheet2.addCell(new jxl.write.Formula(2, B + 9, "SUMA(C9:C" + (B + 8) + " )", plata));
                    sheet2.addCell(new jxl.write.Formula(3, B + 9, "SUMA(D9:D" + (B + 8) + " )", plata));
                    sheet2.addCell(new jxl.write.Formula(4, B + 9, "SUMA(E9:E" + (B + 8) + " )", plata));
                    sheet2.addCell(new jxl.write.Formula(5, B + 9, "SUMA(F9:F" + (B + 8) + " )", plata));
                    sheet2.addCell(new jxl.write.Formula(6, B + 9, "SUMA(G9:G" + (B + 8) + " )", plata));

                    sheet2.addCell(new jxl.write.Label(1, B + 15, "Total Radiografías ", titulo2));
                    sheet2.addCell(new jxl.write.Number(2, B + 15, rayosB, plata));
                    sheet2.addCell(new jxl.write.Label(1, B + 16, "Total Laboratorio ", titulo2));
                    sheet2.addCell(new jxl.write.Number(2, B + 16, labB, plata));
                    
                    /*
                     *                      
                     * La Florida
                     *                      
                     */
                    
                    if (!neg.Cerrado(this.jComboBox9.getSelectedItem().toString(), Integer.parseInt(faño.format(jTextField12.getValue())), "2")) {
                        //          JOptionPane.showMessageDialog(this, "Este Mes NO se encuentra CERRADO, la información \n de este informe puede estar INCOMPLETA.", "Aviso Bandera", JOptionPane.WARNING_MESSAGE);
                        mensaje = "-**INFORME PARCIAL, NO APTO PARA PAGO**-";
                        parcial = true;
                        Iterator itsu = neg.ListarSucursales().iterator();
                        while (itsu.hasNext()) {
                            Sucursales suc = (Sucursales) itsu.next();

                            if (suc.getSucursales().equalsIgnoreCase("La Florida")) {
                                a5 = Double.parseDouble("0." + suc.getParticipacion());
                                s6 = Double.parseDouble("0." + suc.getRetencion());
                            }

                        }
                    } else {
                        Iterator it8 = neg.MesCerrado(this.jComboBox9.getSelectedItem().toString(), Integer.parseInt(faño.format(jTextField12.getValue())), 2).iterator();
                        while (it8.hasNext()) {
                            CerrarMes cm = (CerrarMes) it8.next();
                            a5 = Double.parseDouble("0." + cm.getPorsentaje());
                            s6 = Double.parseDouble("0." + cm.getRetencion());
                        }
                    }

                    WritableSheet sheet3 = workbook.createSheet("La Florida", 3);
                    sheet3.mergeCells(1, 4, 8, 4);
                    sheet3.mergeCells(1, 5, 8, 5);
                    sheet3.addCell(new jxl.write.Label(1, 4, "DENTALES   La Florida " + this.jComboBox9.getSelectedItem().toString(), titulo));
                    sheet3.addCell(new jxl.write.Label(1, 5, mensaje, titulo3));

                    sheet3.getSettings().setProtected(true);
                    for (int cl = 1; cl <= 6; cl++) {
                        sheet3.setColumnView(cl, cv);
                        sheet3.setColumnView(cl, cv);
                    }
                    sheet3.addCell(new jxl.write.Label(1, 7, "Odontologo", titulo2));
                    sheet3.addCell(new jxl.write.Label(2, 7, "Ingreso", titulo2));
                    sheet3.addCell(new jxl.write.Label(3, 7, "Participación", titulo2));
                    sheet3.addCell(new jxl.write.Label(4, 7, "Bono", titulo2));
                    sheet3.addCell(new jxl.write.Label(5, 7, "Retención", titulo2));
                    sheet3.addCell(new jxl.write.Label(6, 7, "Total", titulo2));

                    ArrayList listaPagos= neg.getBuscarPagoGe("" + ValidaFecha(this.jComboBox9.getSelectedIndex() + 1, faño.format(jTextField12.getValue())), "5");
                    Iterator it3 = listaPagos.iterator();

                    int filas3 = listaPagos.size();
                    int f = 0;
                    int rayosF = 0;
                    int labF = 0;
                    for (f = 0; f < filas3; f++) {

                        Pago pag = (Pago) it3.next();

                        sheet3.addCell(new jxl.write.Label(1, f + 8, pag.getDoc_rut()));
                        sheet3.addCell(new jxl.write.Number(2, f + 8, pag.getLiquidacion(), plata));
                        sheet3.addCell(new jxl.write.Formula(3, f + 8, "C" + (9 + f) + "*" + a5, plata));
                        sheet3.addCell(new jxl.write.Number(4, f + 8, pag.getBono(), plata));
                        sheet3.addCell(new jxl.write.Formula(5, f + 8, "(D" + (f + 9) + "+E" + (f + 9) + ")*" + s6, plata));
                        sheet3.addCell(new jxl.write.Formula(6, f + 8, "(E" + (9 + f) + "+D" + (9 + f) + ")-F" + (9 + f), plata));

                        rayosF += pag.getRayosDarsalud();
                        labF += pag.getLaboratorio();
                        if (pag.getDoc_rut().equalsIgnoreCase("AYARZA GOENAGA JULIAN (6888148-K)") && cf.getActivaRetencion().equalsIgnoreCase("true")) {

                            jxl.write.Number label = new jxl.write.Number(5, f + 8, 0, plata);
                            WritableCellFeatures features = new WritableCellFeatures();
                            features.setComment("No Retencion");
                            label.setCellFeatures(features);
                            sheet3.addCell(label);

                        }
                    }

                    sheet3.addCell(new jxl.write.Formula(2, f + 9, "SUMA(C9:C" + (f + 8) + " )", plata));
                    sheet3.addCell(new jxl.write.Formula(3, f + 9, "SUMA(D9:D" + (f + 8) + " )", plata));
                    sheet3.addCell(new jxl.write.Formula(4, f + 9, "SUMA(E9:E" + (f + 8) + " )", plata));
                    sheet3.addCell(new jxl.write.Formula(5, f + 9, "SUMA(F9:F" + (f + 8) + " )", plata));
                    sheet3.addCell(new jxl.write.Formula(6, f + 9, "SUMA(G9:G" + (f + 8) + " )", plata));

                    sheet3.addCell(new jxl.write.Label(1, f + 15, "Total Radiografías ", titulo2));
                    sheet3.addCell(new jxl.write.Number(2, f + 15, rayosF, plata));
                    sheet3.addCell(new jxl.write.Label(1, f + 16, "Total Laboratorio ", titulo2));
                    sheet3.addCell(new jxl.write.Number(2, f + 16, labF, plata));

                    //RESUMEN
                    mensaje = "-**INFORME PARCIAL, NO APTO PARA PAGO**-";

                    WritableSheet sheet4 = workbook.createSheet("RESUMEN", 4);
//                    sheet3.addImage(new WritableImage(0, 0, 2, 5, new File("C:\\dist\\lib\\logoDarSalud.PNG")));

                    sheet4.setColumnView(2, 20);
                    sheet4.setColumnView(3, 15);
                    sheet4.setColumnView(4, 15);
                    sheet4.setColumnView(5, 15);
                    sheet4.setColumnView(6, 15);
                    sheet4.setColumnView(7, 20);

                    sheet4.mergeCells(2, 4, 7, 4);//titulo
                    sheet4.mergeCells(2, 5, 7, 5);//detalle

                    sheet4.addCell(new jxl.write.Label(2, 4, "PAGO DENTAL " + this.jComboBox9.getSelectedItem().toString() + " " + faño.format(jTextField12.getValue()), titulo));

                    sheet4.addCell(new jxl.write.Label(2, 7, "Sucursal", titulo2));
                    sheet4.addCell(new jxl.write.Label(3, 7, "Ingreso", titulo2));
                    sheet4.addCell(new jxl.write.Label(4, 7, "Participación", titulo2));
                    sheet4.addCell(new jxl.write.Label(5, 7, "Bono", titulo2));
                    sheet4.addCell(new jxl.write.Label(6, 7, "Retención", titulo2));
                    sheet4.addCell(new jxl.write.Label(7, 7, "Total", titulo2));

                    sheet4.addCell(new jxl.write.Label(2, 9, "BANDERA"));
                    sheet4.addCell(new jxl.write.Label(2, 11, "MANUEL MONTT"));
                    sheet4.addCell(new jxl.write.Label(2, 13, "SAN ANTONIO"));
                    sheet4.addCell(new jxl.write.Label(2, 15, "LA FLORIDA"));
                    sheet4.addCell(new jxl.write.Label(2, 17, "TOTAL"));

                    sheet4.addCell(new jxl.write.Formula(3, 9, "Bandera!C" + (B + 10), plata));
                    sheet4.addCell(new jxl.write.Formula(4, 9, "Bandera!D" + (B + 10), plata));
                    sheet4.addCell(new jxl.write.Formula(5, 9, "Bandera!E" + (B + 10), plata));
                    sheet4.addCell(new jxl.write.Formula(6, 9, "Bandera!F" + (B + 10), plata));
                    sheet4.addCell(new jxl.write.Formula(7, 9, "Bandera!G" + (B + 10), plata));

                    sheet4.addCell(new jxl.write.Formula(3, 11, "'Manuel Montt'!C" + (M + 10), plata));
                    sheet4.addCell(new jxl.write.Formula(4, 11, "'Manuel Montt'!D" + (M + 10), plata));
                    sheet4.addCell(new jxl.write.Formula(5, 11, "'Manuel Montt'!E" + (M + 10), plata));
                    sheet4.addCell(new jxl.write.Formula(6, 11, "'Manuel Montt'!F" + (M + 10), plata));
                    sheet4.addCell(new jxl.write.Formula(7, 11, "'Manuel Montt'!G" + (M + 10), plata));

                    sheet4.addCell(new jxl.write.Formula(3, 13, "'San Antonio'!C" + (s + 10), plata));
                    sheet4.addCell(new jxl.write.Formula(4, 13, "'San Antonio'!D" + (s + 10), plata));
                    sheet4.addCell(new jxl.write.Formula(5, 13, "'San Antonio'!E" + (s + 10), plata));
                    sheet4.addCell(new jxl.write.Formula(6, 13, "'San Antonio'!F" + (s + 10), plata));
                    sheet4.addCell(new jxl.write.Formula(7, 13, "'San Antonio'!G" + (s + 10), plata));
                    
                    sheet4.addCell(new jxl.write.Formula(3, 15, "'La Florida'!C" + (f + 10), plata));
                    sheet4.addCell(new jxl.write.Formula(4, 15, "'La Florida'!D" + (f + 10), plata));
                    sheet4.addCell(new jxl.write.Formula(5, 15, "'La Florida'!E" + (f + 10), plata));
                    sheet4.addCell(new jxl.write.Formula(6, 15, "'La Florida'!F" + (f + 10), plata));
                    sheet4.addCell(new jxl.write.Formula(7, 15, "'La Florida'!G" + (f + 10), plata));

                    sheet4.addCell(new jxl.write.Formula(3, 17, "SUMA(D10:D16)", plata));
                    sheet4.addCell(new jxl.write.Formula(4, 17, "SUMA(E10:E16)", plata));
                    sheet4.addCell(new jxl.write.Formula(5, 17, "SUMA(F10:F16)", plata));
                    sheet4.addCell(new jxl.write.Formula(6, 17, "SUMA(G10:G16)", plata));
                    sheet4.addCell(new jxl.write.Formula(7, 17, "SUMA(H10:H16)", plata));

                    if (parcial) {
                        sheet4.addCell(new jxl.write.Label(2, 5, mensaje, titulo3));
                    }
                    sheet4.addCell(new jxl.write.Label(2, 20, "Creado en Valkyrie Versión "+ToolUtil.version));

                    workbook.write();
                    workbook.close();
                } catch (IOException ex) {
                    JOptionPane.showMessageDialog(this, "ya tiene el fichero abierto.\n" + ex, "Error", JOptionPane.WARNING_MESSAGE);
                } catch (WriteException ex) {
                    JOptionPane.showMessageDialog(this, "ya tiene el fichero abierto.\n" + ex, "Error", JOptionPane.WARNING_MESSAGE);
                } catch (NumberFormatException ex) {
                    JOptionPane.showMessageDialog(this, "ya tiene el fichero abierto.\n" + ex, "Error", JOptionPane.WARNING_MESSAGE);
                }
                try {
                    Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler  C:\\WINDOWS\\Temp\\Pagos del Mes " + jComboBox9.getSelectedItem().toString() + " Año " + faño.format(jTextField12.getValue()) + ".xls");
                } catch (IOException ee) {
                    JOptionPane.showMessageDialog(this, "ERROR.\n" + ee, "Error", JOptionPane.WARNING_MESSAGE);
                }
            } catch (IOException ex) {
                Logger.getLogger(GUI1.class.getName()).log(Level.SEVERE, null, ex);
            }
        } else {
            JOptionPane.showMessageDialog(this,
                    "Fecha no Corresponde",
                    "Error",
                    JOptionPane.WARNING_MESSAGE);
        }
        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    }//GEN-LAST:event_jbtExExcelDr3ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        if (validaAño(faño.format(jtxtCerrar_Año.getValue()))) {
            try {
                Sucursal su = new Sucursal();
                if (this.jtxtCerrar_Año.getValue().toString().isEmpty()) {
                    JOptionPane.showMessageDialog(this, "Escriva el Año", "Aviso", JOptionPane.INFORMATION_MESSAGE);
                } else {
                    if (neg.Cerrado(this.jcbCerrar_mes.getSelectedItem().toString(), Integer.parseInt(faño.format(this.jtxtCerrar_Año.getValue())), su.getSucursal())) {
                        JOptionPane.showMessageDialog(this, "Este Mes ya se encuentra Cerrado", "Error", JOptionPane.WARNING_MESSAGE);
                    } else {
                        //solo se pueden cerrar 1 mes si el anterior esta cerrado
                        try {
                            if (((jcbCerrar_mes.getSelectedIndex() + 1) - neg.AñoCerrado(faño.format(this.jtxtCerrar_Año.getValue()), su.getSucursal())) == 1) {
                                int opcion = 0;
                                opcion = JOptionPane.showConfirmDialog(this, "¿ESTA SEGURO QUE DESEA CERRAR ESTE MES?", "Confirmacion", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE);
                                if (opcion == JOptionPane.YES_OPTION) {
                                    //ACTUALIZAR EL REGISTRO DE TA TABLA..
                                    NegocioInsert ni = new NegocioInsert();
                                    CerrarMes CM = new CerrarMes();
                                    /*
                                    private String cerradoEl;*/
                                    CM.setMes(this.jcbCerrar_mes.getSelectedItem().toString());
                                    CM.setAño(Integer.parseInt(faño.format(this.jtxtCerrar_Año.getValue())));
                                    CM.setEstado(true);
                                    CM.setRealizadoPor(this.jtxtUser.getText());
                                    CM.setSucursal(su.getSucursal());
                                    CM.setCerradoEl(FechaDia + "/" + FechaMesActual + "/" + FechaAño);
                                    //agregar a la BD
                                    Iterator itsu = neg.ListarSucursales().iterator();
                                    while (itsu.hasNext()) {
                                        Sucursales suc = (Sucursales) itsu.next();
                                        if (suc.getSucursales().equalsIgnoreCase("San Antonio") && su.getSucursal().equalsIgnoreCase("1")) {
                                            CM.setPorsentaje("" + suc.getParticipacion());
                                            CM.setRetencion("" + suc.getRetencion());
                                        }
                                        if (suc.getSucursales().equalsIgnoreCase("Bandera") && su.getSucursal().equalsIgnoreCase("2")) {
                                            CM.setPorsentaje("" + suc.getParticipacion());
                                            CM.setRetencion("" + suc.getRetencion());
                                        }
                                        if (suc.getSucursales().equalsIgnoreCase("Manuel Montt") && su.getSucursal().equalsIgnoreCase("3")) {
                                            CM.setPorsentaje("" + suc.getParticipacion());
                                            CM.setRetencion("" + suc.getRetencion());
                                        }
                                        if (suc.getSucursales().equalsIgnoreCase("La Florida") && su.getSucursal().equalsIgnoreCase("5")) {
                                            CM.setPorsentaje("" + suc.getParticipacion());
                                            CM.setRetencion("" + suc.getRetencion());
                                        }
                                    }
                                    ni.CerrarMes(CM);
                                    JOptionPane.showMessageDialog(this, "Este Mes se a Cerrado", "Aviso", JOptionPane.INFORMATION_MESSAGE);
                                }
                            } else {
                                JOptionPane.showMessageDialog(this, "Solo se pueden cerrar este mes " + "si el mes anterior esta cerrado\n \n Ultimo mes cerrado " + Mes[neg.AñoCerrado(faño.format(this.jtxtCerrar_Año.getValue()), su.getSucursal()) - 1].toUpperCase(), "Aviso", JOptionPane.INFORMATION_MESSAGE);
                            }
                        } catch (ArrayIndexOutOfBoundsException lol) {
                            JOptionPane.showMessageDialog(this, "Debe cerrar Enero para iniciar el año", "Aviso", JOptionPane.INFORMATION_MESSAGE);
                        }
                    }
                }
            } catch (IOException ex) {
                Logger.getLogger(GUI1.class.getName()).log(Level.SEVERE, null, ex);
            }
        } else {

            JOptionPane.showMessageDialog(this,
                    "Fecha no Corresponde",
                    "Error",
                    JOptionPane.WARNING_MESSAGE);
        }
    }//GEN-LAST:event_jButton6ActionPerformed

    private void jcDetalleFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jcDetalleFocusLost
        // TODO add your handling code here:
    }//GEN-LAST:event_jcDetalleFocusLost

    private void jcDetalleKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jcDetalleKeyPressed
        // TODO add your handling code here:
    }//GEN-LAST:event_jcDetalleKeyPressed

    private void jcDetalleMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jcDetalleMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_jcDetalleMouseClicked

    private void jcDetalleMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jcDetalleMousePressed
        // TODO add your handling code here:
    }//GEN-LAST:event_jcDetalleMousePressed

    private void jtxtUserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtxtUserActionPerformed
        // TODO add your handling code here:
        jtxtUser.setText(jtxtUser.getText().toUpperCase());
        this.jtxtPass.requestFocus();
    }//GEN-LAST:event_jtxtUserActionPerformed

    private void jtxtRayosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtxtRayosActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jtxtRayosActionPerformed

    private void jtxtRayosKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtxtRayosKeyTyped
        // TODO add your handling code here:
        char letra = evt.getKeyChar();
        if (letra < '0' || letra > '9') {
            evt.consume();
        } else {
            if (this.jtxtRayos.getText().trim().length() > 9) {
                evt.consume();
            }
        }
    }//GEN-LAST:event_jtxtRayosKeyTyped

    private void jtxtAño1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtxtAño1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jtxtAño1ActionPerformed

    private void jtxtAño1KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtxtAño1KeyTyped
        // TODO add your handling code here:
    }//GEN-LAST:event_jtxtAño1KeyTyped

    private void jcboFecha1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcboFecha1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jcboFecha1ActionPerformed

    private void jbtBuscarDoctor1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtBuscarDoctor1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jbtBuscarDoctor1ActionPerformed

    private void jtxtRayosFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jtxtRayosFocusGained
        // TODO add your handling code here:
        for (int t = 0; t <= nomproce.size() - 1; t++) {
            if (this.jcDetalle.getSelectedItem().toString().equalsIgnoreCase("" + nomproce.get(t))) {
                this.jtxtRayos.setText("" + canti.get(t));
            }
        }
    }//GEN-LAST:event_jtxtRayosFocusGained

    private void jcbLaboratorioFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jcbLaboratorioFocusGained
        // TODO add your handling code here:
        for (int t = 0; t <= nomproce.size() - 1; t++) {
            if (this.jcDetalle.getSelectedItem().toString().equalsIgnoreCase("" + nomproce.get(t))) {
                this.jcbLaboratorio.setText("" + canti.get(t));
            }
        }
    }//GEN-LAST:event_jcbLaboratorioFocusGained

    private void jbtExExcelDr2ActionPerformed1(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtExExcelDr2ActionPerformed1
        setCursor(new Cursor(Cursor.WAIT_CURSOR));
        // segun la sucursal mostrar todas las presupuestos del mes seleccionado
        if (validaAño(faño.format(jTextField11.getValue()))) {
            int filas = 0;
            try {
                String mensaje = "";
                Sucursal su = new Sucursal();
                config cf = new config();
                double a5 = 0;
                double s6 = 0;

                if (!neg.Cerrado(this.jComboBox8.getSelectedItem().toString(), Integer.parseInt(faño.format(jTextField11.getValue())), su.getSucursal())) {
                    //        JOptionPane.showMessageDialog(this, "Este Mes NO se encuentra CERRADO, la información \n de este informe puede estar INCOMPLETA.", "Aviso", JOptionPane.WARNING_MESSAGE);
                    mensaje = "-**INFORME PARCIAL, NO APTO PARA PAGO**-";

                    Iterator itsu = neg.ListarSucursales().iterator();
                    while (itsu.hasNext()) {
                        Sucursales suc = (Sucursales) itsu.next();

                        if (suc.getSucursales().equalsIgnoreCase("San Antonio") && su.getSucursal().equalsIgnoreCase("1")) {
                            a5 = Double.parseDouble("0." + suc.getParticipacion());
                            s6 = Double.parseDouble("0." + suc.getRetencion());
                            //              sheet.addCell(new jxl.write.Label(1, (k + i) + 17, "PARTICIPACION " + suc.getParticipacion() + "%"));
                        }
                        if (suc.getSucursales().equalsIgnoreCase("Bandera") && su.getSucursal().equalsIgnoreCase("2")) {
                            a5 = Double.parseDouble("0." + suc.getParticipacion());
                            s6 = Double.parseDouble("0." + suc.getRetencion());
                            //            sheet.addCell(new jxl.write.Label(1, (k + i) + 17, "PARTICIPACION " + suc.getParticipacion() + "%"));
                        }
                        if (suc.getSucursales().equalsIgnoreCase("Manuel Montt") && su.getSucursal().equalsIgnoreCase("3")) {
                            a5 = Double.parseDouble("0." + suc.getParticipacion());
                            s6 = Double.parseDouble("0." + suc.getRetencion());
                            //           sheet.addCell(new jxl.write.Label(1, (k + i) + 17, "PARTICIPACION " + suc.getParticipacion() + "%"));
                        }
                        if (suc.getSucursales().equalsIgnoreCase("La Florida") && su.getSucursal().equalsIgnoreCase("5")) {
                            a5 = Double.parseDouble("0." + suc.getParticipacion());
                            s6 = Double.parseDouble("0." + suc.getRetencion());
                            //           sheet.addCell(new jxl.write.Label(1, (k + i) + 17, "PARTICIPACION " + suc.getParticipacion() + "%"));
                        }
                    }
                } else {
                    Iterator it8 = neg.MesCerrado(this.jComboBox8.getSelectedItem().toString(), Integer.parseInt(faño.format(jTextField11.getValue())), Integer.parseInt(su.getSucursal())).iterator();
                    while (it8.hasNext()) {
                        CerrarMes cm = (CerrarMes) it8.next();
                        a5 = Double.parseDouble("0." + cm.getPorsentaje());
                        s6 = Double.parseDouble("0." + cm.getRetencion());
                    }
                }
                //Se crea el libro Excel
                WritableWorkbook workbook = Workbook.createWorkbook(new File("C:\\WINDOWS\\Temp\\Sucursal " + this.jTextField1.getText() + " " + this.jComboBox8.getSelectedItem().toString() + " " + faño.format(jTextField11.getValue()) + ".xls"));

                //Se crea una nueva hoja(31caracteres) dentro del libro
                WritableSheet sheet = workbook.createSheet(this.jTextField1.getText(), 0);

                Iterator it = neg.getBuscarPagoDoctorSucursal(Integer.parseInt(su.getSucursal()), ValidaFecha(this.jComboBox8.getSelectedIndex() + 1, faño.format(jTextField11.getValue()))).iterator();
                //formato simple para $
                NumberFormat forma$ = new NumberFormat("$ #,###");
                WritableCellFormat plata = new WritableCellFormat(forma$);

                //indicando un patón de formato color, formato de $
                NumberFormat dp3 = new NumberFormat("$ #,###");
                WritableCellFormat dp3cell = new WritableCellFormat(dp3);
                dp3cell.setBackground(Colour.LIGHT_GREEN);
                dp3cell.setAlignment(Alignment.RIGHT);

                //formato para titulos......
                WritableFont formato1 = new WritableFont(WritableFont.TIMES, 9, WritableFont.BOLD, true);
                formato1.setColour(Colour.BLACK);
                WritableCellFormat titulo = new WritableCellFormat(formato1);
                titulo.setAlignment(Alignment.CENTRE);

                ////////////////////////////////////////////////////////////////////////////////////////////////////
                //repetir esto, segun la cantidad de datos rescatados....

                filas = neg.getBuscarPagoDoctorSucursal(Integer.parseInt(su.getSucursal()),
                        ValidaFecha(this.jComboBox8.getSelectedIndex() + 1, faño.format(jTextField11.getValue()))).size();

                sheet.addCell(new jxl.write.Label(0, 0, "Creado en Valkyrie Versión "+ToolUtil.version));

                WritableCellFormat centrado = new WritableCellFormat();
                centrado.setAlignment(Alignment.CENTRE);

                sheet.addCell(new jxl.write.Label(1, 1, "FECHA NOMINA", centrado));
                sheet.addCell(new jxl.write.Label(1, 2, "Inicio 01/" + jComboBox8.getSelectedItem().toString() + "/" + faño.format(jTextField11.getValue()), centrado));
                sheet.addCell(new jxl.write.Label(1, 3, "Termino " + ValidaFecha(jComboBox8.getSelectedIndex() + 1, faño.format(jTextField11.getValue())) + "/" + jComboBox8.getSelectedItem().toString() + "/" + faño.format(jTextField11.getValue()), centrado));

                //fecha actual
                sheet.addCell(new jxl.write.Label(3, 1, "Fecha Actual", centrado));
                sheet.addCell(new jxl.write.Label(3, 2, FechaDia + "/" + Mes[Integer.parseInt(FechaMesActual) - 1] + "/" + FechaAño, centrado));

                WritableFont formato2 = new WritableFont(WritableFont.ARIAL, 14, WritableFont.NO_BOLD, false);
                formato2.setColour(Colour.BLACK);
                WritableCellFormat titulo1 = new WritableCellFormat(formato2);
                titulo1.setAlignment(Alignment.CENTRE);

                //fucion de celdas
                sheet.mergeCells(0, 5, 6, 5);//titulo

                sheet.addCell(new jxl.write.Label(0, 5, "PAGOS TODOS LOS ODONTOLOGOS", titulo1));

                sheet.addCell(new jxl.write.Label(1, 6, "Sucursal: " + this.jLabelSucursalInformes.getText(), centrado));
                sheet.addCell(new jxl.write.Label(0, 1, "Usuario: " + this.jtxtUser.getText()));

                sheet.setColumnView(0, 45);
                sheet.setColumnView(1, 45);
                sheet.setColumnView(2, 10);
                sheet.setColumnView(3, 10);
                sheet.setColumnView(4, 10);
                sheet.setColumnView(5, 10);
                sheet.setColumnView(6, 10);
                sheet.setColumnView(7, 10);

                sheet.addCell(new jxl.write.Label(0, 8, "DR.(A) ", titulo));
                sheet.addCell(new jxl.write.Label(1, 8, "PACIENTE", titulo));
                sheet.addCell(new jxl.write.Label(2, 8, "# PRESUP.", titulo));
                sheet.addCell(new jxl.write.Label(3, 8, "MONTO PTO.", titulo));
                sheet.addCell(new jxl.write.Label(4, 8, this.jComboBox8.getSelectedItem().toString() + " " + faño.format(jTextField11.getValue()), titulo));
                sheet.addCell(new jxl.write.Label(5, 8, "Boletas", titulo));
                sheet.addCell(new jxl.write.Label(6, 8, "Laboratorios", titulo));
                sheet.addCell(new jxl.write.Label(7, 8, "Bonos", titulo));

                boolean valida = false;
                String rutAnteriro = "";
                int i = 0;
                int k = 0;

                for (int ok = 0; ok < filas; ok++) {

                    Pago pag = (Pago) it.next();

                    if (valida) {//para que compare la 2° vez
                        if (!rutAnteriro.equalsIgnoreCase(pag.getDoc_rut())) {

                            sheet.addCell(new jxl.write.Label(0, i + 12, "TOTAL"));

                            if (!neg.Cerrado(this.jComboBox8.getSelectedItem().toString(), Integer.parseInt(faño.format(jTextField11.getValue())), su.getSucursal())) {
                                Iterator itsu = neg.ListarSucursales().iterator();
                                while (itsu.hasNext()) {
                                    Sucursales suc = (Sucursales) itsu.next();

                                    if (suc.getSucursales().equalsIgnoreCase("San Antonio") && su.getSucursal().equalsIgnoreCase("1")) {
                                        sheet.addCell(new jxl.write.Label(0, i + 13, "PARTICIPACION " + suc.getParticipacion() + "%"));
                                    }
                                    if (suc.getSucursales().equalsIgnoreCase("Bandera") && su.getSucursal().equalsIgnoreCase("2")) {
                                        sheet.addCell(new jxl.write.Label(0, i + 13, "PARTICIPACION " + suc.getParticipacion() + "%"));
                                    }
                                    if (suc.getSucursales().equalsIgnoreCase("Manuel Montt") && su.getSucursal().equalsIgnoreCase("3")) {
                                        sheet.addCell(new jxl.write.Label(0, i + 13, "PARTICIPACION " + suc.getParticipacion() + "%"));
                                    }
                                    if (suc.getSucursales().equalsIgnoreCase("La Florida") && su.getSucursal().equalsIgnoreCase("5")) {
                                        sheet.addCell(new jxl.write.Label(0, i + 13, "PARTICIPACION " + suc.getParticipacion() + "%"));
                                    }
                                }
                            } else {
                                Iterator it8 = neg.MesCerrado(this.jComboBox8.getSelectedItem().toString(), Integer.parseInt(faño.format(jTextField11.getValue())), Integer.parseInt(su.getSucursal())).iterator();
                                while (it8.hasNext()) {
                                    CerrarMes cm = (CerrarMes) it8.next();
                                    sheet.addCell(new jxl.write.Label(0, i + 13, "PARTICIPACION " + cm.getPorsentaje() + "%"));

                                }
                            }

                            sheet.addCell(new jxl.write.Label(0, i + 14, "RETENCION  " + (s6 * 100) + "% "));
                            sheet.addCell(new jxl.write.Label(0, i + 15, "TOTAL A PAGAR"));

                            //otras formulas ....
                            sheet.addCell(new Formula(1, i + 12, "SUMA(E" + ((i + 9) - k) + ":E" + (i + 9) + ")", dp3cell));

                            if (rutAnteriro.equalsIgnoreCase("AYARZA GOENAGA JULIAN (6888148-K)") && cf.getActivaRetencion().equalsIgnoreCase("true")) {
                                sheet.addCell(new Formula(1, i + 13, "b" + (i + 13) + "*" + a5, dp3cell));
                                sheet.addCell(new jxl.write.Label(1, i + 14, "NO RETENCION"));
                                sheet.addCell(new Formula(1, i + 15, "b" + (i + 14) + "+ SUMA(H" + ((i + 9) - k) + ":H" + (i + 9) + ")", dp3cell));

                            } else {
                                sheet.addCell(new Formula(1, i + 13, "b" + (i + 13) + "*" + a5, dp3cell));
                                sheet.addCell(new Formula(1, i + 14, "(b" + (i + 14) + "+ SUMA(H" + ((i + 9) - k) + ":H" + (i + 9) + "))*" + s6, dp3cell));
                                sheet.addCell(new Formula(1, i + 15, "b" + (i + 14) + "-b" + (i + 15), dp3cell));
                            }
                            k = 0;
                            i = i + 10;
                        } else {
                            k++;
                        }
                    }

                    valida = true;
                    rutAnteriro = pag.getDoc_rut();

                    sheet.addCell(new jxl.write.Label(0, i + 9, pag.getDoc_rut()));

                    sheet.addCell(new jxl.write.Label(1, i + 9, pag.getPaciente_rut()));
                    //presupuestos desde 2-2(colum-fila)

                    sheet.addCell(new jxl.write.Number(2, i + 9, pag.getNumero_presupuesto()));
                    //CANTIDAD TOTAL DEL PRESUPUESTO

                    sheet.addCell(new jxl.write.Number(3, i + 9, pag.getValorPrestacion()==0 ? CalcularPresu(pag.getNumero_presupuesto()): pag.getValorPrestacion(), plata));
                    /////////////////////////////////////////////////////////////////////
                    sheet.addCell(new jxl.write.Number(5, i + 9, pag.getPag_num_boleta()));
                    jxl.write.Number label = new jxl.write.Number(4, i + 9, pag.getLiquidacion(), dp3cell);
                    sheet.addCell(new jxl.write.Number(6, i + 9, pag.getLaboratorio(), plata));
                    sheet.addCell(new jxl.write.Number(7, i + 9, pag.getBono(), plata));
                    ////////////////////////////////////////////////////////////////////////////////////////
                    //desde el 2-41

                    WritableCellFeatures features = new WritableCellFeatures();

                    features.setComment(pag.getFecha().substring(8, 10) + "-"
                            + pag.getFecha().substring(5, 7) + "-" + pag.getFecha().substring(0, 4) + "\n "
                            + pag.getDetalle());
                    label.setCellFeatures(features);

                    sheet.addCell(label);

                    i++;
                }

                sheet.addCell(new jxl.write.Label(0, i + 13, "TOTAL"));

                if (!neg.Cerrado(this.jComboBox8.getSelectedItem().toString(), Integer.parseInt(faño.format(jTextField11.getValue())), su.getSucursal())) {

                    Iterator itsu = neg.ListarSucursales().iterator();
                    while (itsu.hasNext()) {
                        Sucursales suc = (Sucursales) itsu.next();

                        if (suc.getSucursales().equalsIgnoreCase("San Antonio") && su.getSucursal().equalsIgnoreCase("1")) {
                            sheet.addCell(new jxl.write.Label(0, i + 14, "PARTICIPACION " + suc.getParticipacion() + "%"));
                        }
                        if (suc.getSucursales().equalsIgnoreCase("Bandera") && su.getSucursal().equalsIgnoreCase("2")) {
                            sheet.addCell(new jxl.write.Label(0, i + 14, "PARTICIPACION " + suc.getParticipacion() + "%"));
                        }
                        if (suc.getSucursales().equalsIgnoreCase("Manuel Montt") && su.getSucursal().equalsIgnoreCase("3")) {
                            sheet.addCell(new jxl.write.Label(0, i + 14, "PARTICIPACION " + suc.getParticipacion() + "%"));
                        }
                        if (suc.getSucursales().equalsIgnoreCase("La Florida") && su.getSucursal().equalsIgnoreCase("5")) {
                            sheet.addCell(new jxl.write.Label(0, i + 14, "PARTICIPACION " + suc.getParticipacion() + "%"));
                        }
                    }

                } else {
                    Iterator it8 = neg.MesCerrado(this.jComboBox8.getSelectedItem().toString(), Integer.parseInt(faño.format(jTextField11.getValue())), Integer.parseInt(su.getSucursal())).iterator();
                    while (it8.hasNext()) {
                        CerrarMes cm = (CerrarMes) it8.next();
                        sheet.addCell(new jxl.write.Label(0, i + 14, "PARTICIPACION " + cm.getPorsentaje() + "%"));

                    }
                }
                sheet.addCell(new jxl.write.Label(0, i + 15, "RETENCION  " + (s6 * 100) + "% "));
                sheet.addCell(new jxl.write.Label(0, i + 16, "TOTAL A PAGAR"));

                sheet.addCell(new Formula(1, i + 13, "SUMA(E" + (i - (k - 9)) + ":E" + (i + 9) + ")", dp3cell));
                sheet.addCell(new Formula(1, i + 14, "b" + (i + 14) + "*" + a5, dp3cell));
                sheet.addCell(new Formula(1, i + 15, "(b" + (i + 15) + "+ SUMA(H" + ((i + 9) - k) + ":H" + (i + 9) + "))*" + s6, dp3cell));
                sheet.addCell(new Formula(1, i + 16, "b" + (i + 15) + "-b" + (i + 16) + ")", dp3cell));

                sheet.mergeCells(0, (k + i) + 5, 5, (k + i) + 5);
                sheet.addCell(new jxl.write.Label(0, (k + i) + 5, mensaje, titulo));

                workbook.write();
                workbook.close();

            } catch (IOException ex) {
                JOptionPane.showMessageDialog(this, "ya tiene el fichero abierto.\n" + ex,
                        "Error", JOptionPane.WARNING_MESSAGE);
            } catch (NumberFormatException ex) {
                JOptionPane.showMessageDialog(this, "ya tiene el fichero abierto.\n" + ex,
                        "Error", JOptionPane.WARNING_MESSAGE);
            } catch (WriteException ex) {
                JOptionPane.showMessageDialog(this, "ya tiene el fichero abierto.\n" + ex,
                        "Error", JOptionPane.WARNING_MESSAGE);
            }
            //abriendo el el excel
            try {
                if (filas > 0) {
                    Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler  C:\\WINDOWS\\Temp\\Sucursal " + this.jTextField1.getText() + " " + this.jComboBox8.getSelectedItem().toString() + " " + faño.format(jTextField11.getValue()) + ".xls");
                } else {
                    JOptionPane.showMessageDialog(this, "No tiene informacion");
                }
            } catch (IOException ee) {
                JOptionPane.showMessageDialog(this, "ERROR.\n" + ee,
                        "Error", JOptionPane.WARNING_MESSAGE);
            }
        } else {
            JOptionPane.showMessageDialog(this,
                    "Fecha no Corresponde",
                    "Error",
                    JOptionPane.WARNING_MESSAGE);
        }
        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    }//GEN-LAST:event_jbtExExcelDr2ActionPerformed1

    private void jbtManUserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtManUserActionPerformed
        // TODO add your handling code here:
        jTextField28.setText(jtxtUser.getText());
        jPasswordField4.setText("");
        jPasswordField4.setEnabled(true);
        jPasswordField4.setEditable(true);

        jButton2.setEnabled(true);
        jbCuModificar.setEnabled(false);//
        jbCuNuevo.setEnabled(false);//
        jbcuEliminar.setEnabled(false);

        this.jbcuLimpiar.setEnabled(false);//
        this.jbCuGuardar.setEnabled(false);//

        //texto
        jTextField30.removeAllItems();
        jTextField31.setText("");
        jTextField32.setText("");
        jTextField33.setText("");
        jTextField34.setText("");
        //paswords

        jPasswordField2.setText("");
        jPasswordField3.setText("");
        // jPasswordField4.setText("");

        //textoActivar
        jTextField30.setEditable(false);
        jTextField31.setEditable(false);
        jTextField32.setEditable(false);
        jTextField33.setEditable(false);
        jTextField34.setEditable(false);
        //paswords

        jPasswordField2.setEditable(false);
        jPasswordField3.setEditable(false);


        //privilegios
        jCheckBox14.setSelected(false);
        jCheckBox15.setSelected(false);
        jCheckBox16.setSelected(false);
        jCheckBox17.setSelected(false);
        jCheckBox18.setSelected(false);
        jCheckBox19.setSelected(false);
        jCheckBox20.setSelected(false);
        jCheckBox21.setSelected(false);
        jCheckBox22.setSelected(false);
        jCheckBox23.setSelected(false);
        jCheckBox24.setSelected(false);
        jCheckBox25.setSelected(false);
        jCheckBox26.setSelected(false);

        jCheckBox14.setEnabled(false);
        jCheckBox15.setEnabled(false);
        jCheckBox16.setEnabled(false);
        jCheckBox17.setEnabled(false);
        jCheckBox18.setEnabled(false);
        jCheckBox19.setEnabled(false);
        jCheckBox20.setEnabled(false);
        jCheckBox21.setEnabled(false);
        jCheckBox22.setEnabled(false);
        jCheckBox23.setEnabled(false);
        jCheckBox24.setEnabled(false);
        jCheckBox25.setEnabled(false);
        jCheckBox26.setEnabled(false);
        jTextField30.setEnabled(false);

        ControlAcceso.setVisible(true);
        ControlAcceso.pack();
        ControlAcceso.setAlwaysOnTop(true);
        ControlAcceso.setLocation(200, 70);

    }//GEN-LAST:event_jbtManUserActionPerformed

    private void jbtGuardarBonoActionPerformed1(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtGuardarBonoActionPerformed1
        try {
            Sucursal su = new Sucursal();
            if (neg.Cerrado(this.jComboBox4.getSelectedItem().toString(), Integer.parseInt(FechaAño), su.getSucursal())) {
                JOptionPane.showMessageDialog(this,
                        "Este Mes ya se encuentra Cerrado",
                        "Error",
                        JOptionPane.WARNING_MESSAGE);
            } else {
                if (!this.jComboBox5.getSelectedItem().toString().trim().isEmpty() && !jComboBox5.getSelectedItem().toString().equalsIgnoreCase("Selecione Odontologo")) {


                    if (!this.jTextField6.getText().isEmpty() && !jComboBox1.getSelectedItem().toString().isEmpty() && !jComboBox5.getSelectedItem().toString().isEmpty()) {

                        int opcion = 0;
                        opcion = JOptionPane.showConfirmDialog(this,
                                "¿Desea Guardar este Bono?",
                                "Confirmacion",
                                JOptionPane.YES_NO_OPTION,
                                JOptionPane.INFORMATION_MESSAGE);
                        if (opcion == JOptionPane.YES_OPTION) {
                            Pago pag = new Pago();
                            pag.setNumero_presupuesto(1);
                            pag.setDoc_rut(this.jComboBox5.getSelectedItem().toString());
                            pag.setPaciente_rut("Bono DarSalud");
                            pag.setPag_num_boleta(1);
                            pag.setLiquidacion(0);
                            pag.setLaboratorio(0);
                            pag.setBono(Integer.parseInt(this.jTextField6.getText()));
                            //seteo fecha desde el equipo. .dia / mes / año
//                    Date fechaActual = new Date();
//                    SimpleDateFormat formato = new SimpleDateFormat("yyyyMMdd");
//                    String FechaAño = formato.format(fechaActual).substring(0, 4);

                            pag.setGuardadoEl(FechaDia + "/" + FechaMesActual + "/" + FechaAño);
                            int mm = this.jComboBox4.getSelectedIndex() + 1;
                            String FechaMes = "" + mm;
                            for (int num = 1; num <= 9; num++) {
                                if (mm == num) {
                                    //agrego un 0 si es mes es menor a 9
                                    FechaMes = "0" + mm;
                                }
                            }
                            pag.setRayosDarsalud(0);
                            pag.setFecha(FechaDia + "/" + FechaMes + "/" + faño.format(this.jtxtAñoBono.getValue()));
                            pag.setDetalle(this.jComboBox1.getSelectedItem().toString());
                            pag.setCOD_SUCURSAL(su.getSucursal());
                            pag.setIngresoPor(this.jtxtUser.getText());
                            NegocioInsert ni = new NegocioInsert();

                            ni.agregarPago(pag);
                            //mostrar abonos ingresados,

                            this.jComboBox5.setSelectedIndex(0);
                            this.jTextField6.setText("");

                        }
                    } else {
                        JOptionPane.showMessageDialog(this, " Falta Informacion ", "Error", JOptionPane.WARNING_MESSAGE);
                    }
                } else {

                    JOptionPane.showMessageDialog(this,
                            "No se a Selecionado un Odontologo",
                            "Error",
                            JOptionPane.WARNING_MESSAGE);
                    this.jcboDoctor.requestFocus();
                }
            }
        } catch (IOException ex) {
            Logger.getLogger(GUI1.class.getName()).log(Level.SEVERE, null, ex);
        }
        // TODO add your handling code here:
    }//GEN-LAST:event_jbtGuardarBonoActionPerformed1

    private void jTextField14KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField14KeyTyped
        // TODO add your handling code here:
}//GEN-LAST:event_jTextField14KeyTyped

    private void jTextField14KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField14KeyPressed
}//GEN-LAST:event_jTextField14KeyPressed

    private void jTextField14StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jTextField14StateChanged
    }//GEN-LAST:event_jTextField14StateChanged

    private void jbCuNuevoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbCuNuevoActionPerformed
        // TODO add your handling code here:
        this.jlError.setText("");
        op.setText("nuevo");
        jbCuModificar.setEnabled(false);//
        jbCuNuevo.setEnabled(false);//
        jbcuEliminar.setEnabled(false);//

        jbcuLimpiar.setEnabled(true);//
        jbCuGuardar.setEnabled(true);//

        //texto
        jTextField30.removeAllItems();
        jTextField31.setText("");
        jTextField32.setText("");
        jTextField33.setText("");
        jTextField34.setText("");
        //paswords

        jPasswordField2.setText("");
        jPasswordField3.setText("");
        //   jPasswordField4.setText("");

        //textoActivar
        jTextField30.setEditable(true);
        jTextField31.setEditable(true);
        jTextField32.setEditable(true);
        jTextField33.setEditable(true);
        jTextField34.setEditable(true);
        //paswords

        jPasswordField2.setEditable(true);
        jPasswordField3.setEditable(true);
        //    jPasswordField4.setEditable(true);

        //texto
        jTextField30.setEnabled(true);
        jTextField31.setEnabled(true);
        jTextField32.setEnabled(true);
        jTextField33.setEnabled(true);
        jTextField34.setEnabled(true);
        //paswords

        jPasswordField2.setEnabled(true);
        jPasswordField3.setEnabled(true);
        //     jPasswordField4.setEnabled(true);

        //privilegios
        jCheckBox14.setSelected(false);
        jCheckBox15.setSelected(false);
        jCheckBox16.setSelected(false);
        jCheckBox17.setSelected(false);
        jCheckBox18.setSelected(false);
        jCheckBox19.setSelected(false);
        jCheckBox20.setSelected(false);
        jCheckBox21.setSelected(false);
        jCheckBox22.setSelected(false);
        jCheckBox23.setSelected(false);
        jCheckBox24.setSelected(false);
        jCheckBox25.setSelected(false);
        jCheckBox26.setSelected(false);

        jCheckBox14.setEnabled(true);
        jCheckBox15.setEnabled(true);
        jCheckBox16.setEnabled(true);
        jCheckBox17.setEnabled(true);
        jCheckBox18.setEnabled(true);
        jCheckBox19.setEnabled(true);
        jCheckBox20.setEnabled(true);
        jCheckBox21.setEnabled(true);
        jCheckBox22.setEnabled(true);
        jCheckBox23.setEnabled(true);
        jCheckBox24.setEnabled(true);
        jCheckBox25.setEnabled(true);
        jCheckBox26.setEnabled(true);


    }//GEN-LAST:event_jbCuNuevoActionPerformed

    private void jbCuGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbCuGuardarActionPerformed
        // TODO add your handling code here:
        //validar los datos..

        if (op.getText().equalsIgnoreCase("modificar")) {
            if (jTextField32.getText().isEmpty()) {
                this.jlError.setText("Escriva el Apellido paterno");
                jTextField32.requestFocus();
            } else {
                if (jTextField33.getText().isEmpty()) {
                    this.jlError.setText("Escriva el Apellido materno");
                    jTextField33.requestFocus();
                } else {
                    if (jTextField34.getText().isEmpty()) {
                        this.jlError.setText("Escriva el Nombre");
                        jTextField34.requestFocus();
                    } else {
                        if (jTextField31.getText().isEmpty()) {
                            this.jlError.setText("Escriva el Cargo");
                            jTextField31.requestFocus();
                        } else {
                            if (this.jPasswordField3.getText().trim().equalsIgnoreCase(jPasswordField2.getText().trim())) {
                                //actualizar el usuario..
                                Usuarios us = new Usuarios();
                                NegocioInsert ni = new NegocioInsert();

                                us.setUsuario(jTextField30.getSelectedItem().toString());
                                us.setPass(this.jPasswordField3.getText().trim());

                                us.setCambioSucursal(this.jCheckBox15.isSelected());
                                us.setBonosViaje(jCheckBox24.isSelected());
                                us.setAdmin(jCheckBox22.isSelected());
                                us.setGuardar(jCheckBox21.isSelected());
                                us.setVerbono(jCheckBox26.isSelected());
                                us.setVer(jCheckBox23.isSelected());
                                us.setLiquiMes(jCheckBox25.isSelected());
                                us.setLiquiAño(jCheckBox18.isSelected());
                                us.setLiquiTodos(jCheckBox20.isSelected());
                                us.setLiquiGerencia(jCheckBox19.isSelected());
                                us.setEliminar(jCheckBox17.isSelected());
                                us.setEliminarMes(jCheckBox16.isSelected());
                                us.setCerrarMes(jCheckBox14.isSelected());

                                us.setApePat(jTextField32.getText());
                                us.setApeMat(jTextField33.getText());
                                us.setNombre(jTextField34.getText());
                                us.setCargo(jTextField31.getText());

                                ni.ModificarPrivilegios(us);
                                this.jlError.setText("Modificado " + jTextField30.getSelectedItem().toString());
                                this.jbCuModificar.setEnabled(true);//
                                this.jbCuNuevo.setEnabled(true);//
                                jbcuEliminar.setEnabled(true);//

                                this.jbcuLimpiar.setEnabled(false);//
                                this.jbCuGuardar.setEnabled(false);//

                                //texto
                                jTextField30.removeAllItems();
                                jTextField31.setText("");
                                jTextField32.setText("");
                                jTextField33.setText("");
                                jTextField34.setText("");
                                //paswords

                                jPasswordField2.setText("");
                                jPasswordField3.setText("");

                                //textoActivar
                                jTextField30.setEditable(false);
                                jTextField31.setEditable(false);
                                jTextField32.setEditable(false);
                                jTextField33.setEditable(false);
                                jTextField34.setEditable(false);

                                //paswords
                                jPasswordField2.setEditable(false);
                                jPasswordField3.setEditable(false);

                                //privilegios
                                jCheckBox14.setSelected(false);
                                jCheckBox15.setSelected(false);
                                jCheckBox16.setSelected(false);
                                jCheckBox17.setSelected(false);
                                jCheckBox18.setSelected(false);
                                jCheckBox19.setSelected(false);
                                jCheckBox20.setSelected(false);
                                jCheckBox21.setSelected(false);
                                jCheckBox22.setSelected(false);
                                jCheckBox23.setSelected(false);
                                jCheckBox24.setSelected(false);
                                jCheckBox25.setSelected(false);
                                jCheckBox26.setSelected(false);

                                jCheckBox14.setEnabled(false);
                                jCheckBox15.setEnabled(false);
                                jCheckBox16.setEnabled(false);
                                jCheckBox17.setEnabled(false);
                                jCheckBox18.setEnabled(false);
                                jCheckBox19.setEnabled(false);
                                jCheckBox20.setEnabled(false);
                                jCheckBox21.setEnabled(false);
                                jCheckBox22.setEnabled(false);
                                jCheckBox23.setEnabled(false);
                                jCheckBox24.setEnabled(false);
                                jCheckBox25.setEnabled(false);
                                jCheckBox26.setEnabled(false);
                                jTextField30.setEnabled(false);
                                op.setText("");
                            } else {
                                this.jlError.setText("Contraseñas no son iguales");

                            }
                        }
                    }
                }
            }
        }

        if (op.getText().equalsIgnoreCase("eliminar")) {

            NegocioInsert ni = new NegocioInsert();

            this.jlError.setText("Eliminado " + jTextField30.getSelectedItem().toString());

            ni.EliminiarUser(jTextField30.getSelectedItem().toString().trim());

            this.jbCuModificar.setEnabled(true);//
            this.jbCuNuevo.setEnabled(true);//
            jbcuEliminar.setEnabled(true);//

            this.jbcuLimpiar.setEnabled(false);//
            this.jbCuGuardar.setEnabled(false);//

            //texto
            jTextField30.removeAllItems();
            jTextField31.setText("");
            jTextField32.setText("");
            jTextField33.setText("");
            jTextField34.setText("");
            //paswords

            jPasswordField2.setText("");
            jPasswordField3.setText("");

            //textoActivar
            jTextField30.setEditable(false);
            jTextField31.setEditable(false);
            jTextField32.setEditable(false);
            jTextField33.setEditable(false);
            jTextField34.setEditable(false);

            //paswords
            jPasswordField2.setEditable(false);
            jPasswordField3.setEditable(false);

            //privilegios
            jCheckBox14.setSelected(false);
            jCheckBox15.setSelected(false);
            jCheckBox16.setSelected(false);
            jCheckBox17.setSelected(false);
            jCheckBox18.setSelected(false);
            jCheckBox19.setSelected(false);
            jCheckBox20.setSelected(false);
            jCheckBox21.setSelected(false);
            jCheckBox22.setSelected(false);
            jCheckBox23.setSelected(false);
            jCheckBox24.setSelected(false);
            jCheckBox25.setSelected(false);
            jCheckBox26.setSelected(false);

            jCheckBox14.setEnabled(false);
            jCheckBox15.setEnabled(false);
            jCheckBox16.setEnabled(false);
            jCheckBox17.setEnabled(false);
            jCheckBox18.setEnabled(false);
            jCheckBox19.setEnabled(false);
            jCheckBox20.setEnabled(false);
            jCheckBox21.setEnabled(false);
            jCheckBox22.setEnabled(false);
            jCheckBox23.setEnabled(false);
            jCheckBox24.setEnabled(false);
            jCheckBox25.setEnabled(false);
            jCheckBox26.setEnabled(false);
            jTextField30.setEnabled(false);
            op.setText("");

        }

        if (op.getText().equalsIgnoreCase("nuevo")) {
            if (jTextField32.getText().isEmpty()) {
                this.jlError.setText("Escriva el Apellido paterno");
                jTextField32.requestFocus();
            } else {
                if (jTextField33.getText().isEmpty()) {
                    this.jlError.setText("Escriva el Apellido materno");
                    jTextField33.requestFocus();
                } else {
                    if (jTextField34.getText().isEmpty()) {
                        this.jlError.setText("Escriva el Nombre");
                        jTextField34.requestFocus();
                    } else {
                        if (jTextField30.getSelectedItem().toString().isEmpty()) {
                            this.jlError.setText("Escriva el Nombre de usuario");
                            jTextField30.requestFocus();
                        } else {
                            if (jTextField31.getText().isEmpty()) {
                                this.jlError.setText("Escriva el Cargo");
                                jTextField31.requestFocus();
                            } else {
                                if (this.jPasswordField3.getText().trim().equalsIgnoreCase(jPasswordField2.getText().trim())) {
                                    //actualizar el usuario..

                                    Usuarios us = new Usuarios();
                                    NegocioInsert ni = new NegocioInsert();

                                    Iterator user = neg.ListarUser().iterator();
                                    boolean x = true;

                                    while (user.hasNext()) {
                                        Usuarios us2 = (Usuarios) user.next();

                                        if (us2.getUsuario().equalsIgnoreCase(jTextField30.getSelectedItem().toString())) {
                                            x = false;
                                        }

                                    }
                                    if (x) {
                                        us.setUsuario(jTextField30.getSelectedItem().toString());
                                        us.setPass(this.jPasswordField3.getText().trim());

                                        us.setCambioSucursal(this.jCheckBox15.isSelected());
                                        us.setBonosViaje(jCheckBox24.isSelected());
                                        us.setAdmin(jCheckBox22.isSelected());
                                        us.setGuardar(jCheckBox21.isSelected());
                                        us.setVerbono(jCheckBox26.isSelected());
                                        us.setVer(jCheckBox23.isSelected());
                                        us.setLiquiMes(jCheckBox25.isSelected());
                                        us.setLiquiAño(jCheckBox18.isSelected());
                                        us.setLiquiTodos(jCheckBox20.isSelected());
                                        us.setLiquiGerencia(jCheckBox19.isSelected());
                                        us.setEliminar(jCheckBox17.isSelected());
                                        us.setEliminarMes(jCheckBox16.isSelected());
                                        us.setCerrarMes(jCheckBox14.isSelected());

                                        us.setApePat(jTextField32.getText());
                                        us.setApeMat(jTextField33.getText());
                                        us.setNombre(jTextField34.getText());
                                        us.setCargo(jTextField31.getText());

                                        ni.AgregarUser(us);

                                        this.jlError.setText("Agregado " + jTextField30.getSelectedItem().toString());
                                        this.jbCuModificar.setEnabled(true);//
                                        this.jbCuNuevo.setEnabled(true);//
                                        jbcuEliminar.setEnabled(true);//

                                        this.jbcuLimpiar.setEnabled(false);//
                                        this.jbCuGuardar.setEnabled(false);//

                                        //texto
                                        jTextField30.removeAllItems();
                                        jTextField31.setText("");
                                        jTextField32.setText("");
                                        jTextField33.setText("");
                                        jTextField34.setText("");
                                        //paswords

                                        jPasswordField2.setText("");
                                        jPasswordField3.setText("");

                                        //textoActivar
                                        jTextField30.setEditable(false);
                                        jTextField31.setEditable(false);
                                        jTextField32.setEditable(false);
                                        jTextField33.setEditable(false);
                                        jTextField34.setEditable(false);

                                        //paswords
                                        jPasswordField2.setEditable(false);
                                        jPasswordField3.setEditable(false);

                                        //privilegios
                                        jCheckBox14.setSelected(false);
                                        jCheckBox15.setSelected(false);
                                        jCheckBox16.setSelected(false);
                                        jCheckBox17.setSelected(false);
                                        jCheckBox18.setSelected(false);
                                        jCheckBox19.setSelected(false);
                                        jCheckBox20.setSelected(false);
                                        jCheckBox21.setSelected(false);
                                        jCheckBox22.setSelected(false);
                                        jCheckBox23.setSelected(false);
                                        jCheckBox24.setSelected(false);
                                        jCheckBox25.setSelected(false);
                                        jCheckBox26.setSelected(false);

                                        jCheckBox14.setEnabled(false);
                                        jCheckBox15.setEnabled(false);
                                        jCheckBox16.setEnabled(false);
                                        jCheckBox17.setEnabled(false);
                                        jCheckBox18.setEnabled(false);
                                        jCheckBox19.setEnabled(false);
                                        jCheckBox20.setEnabled(false);
                                        jCheckBox21.setEnabled(false);
                                        jCheckBox22.setEnabled(false);
                                        jCheckBox23.setEnabled(false);
                                        jCheckBox24.setEnabled(false);
                                        jCheckBox25.setEnabled(false);
                                        jCheckBox26.setEnabled(false);
                                        jTextField30.setEnabled(false);
                                        op.setText("");

                                    } else {
                                        this.jlError.setText("Nombres de usuario son iguales");
                                    }
                                } else {
                                    this.jlError.setText("Contraseñas no son iguales");

                                }
                            }
                        }
                    }
                }
            }
        }

    }//GEN-LAST:event_jbCuGuardarActionPerformed

    private void jbCuModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbCuModificarActionPerformed
        // TODO add your handling code here:
        this.jlError.setText("");
        op.setText("modificar");
        Iterator user = neg.ListarUser().iterator();

        while (user.hasNext()) {
            Usuarios us = (Usuarios) user.next();
            jTextField30.addItem(us.getUsuario());
        }

        this.jbCuModificar.setEnabled(false);//
        this.jbCuNuevo.setEnabled(false);//
        jbcuEliminar.setEnabled(false);//

        this.jbcuLimpiar.setEnabled(true);//
        this.jbCuGuardar.setEnabled(true);//

        //texto
        //  jTextField30.setText("");
        jTextField31.setText("");
        jTextField32.setText("");
        jTextField33.setText("");
        jTextField34.setText("");
        //paswords

        jPasswordField2.setText("");
        jPasswordField3.setText("");
        //    jPasswordField4.setText("");

        //activo
        //texto
        jTextField30.setEnabled(true);
        jTextField31.setEditable(true);
        jTextField32.setEditable(true);
        jTextField33.setEditable(true);
        jTextField34.setEditable(true);
        //paswords
        jTextField30.setEditable(false);
        jPasswordField2.setEditable(true);
        jPasswordField3.setEditable(true);

        //texto
        //  jTextField30.setEnabled(true);
        jTextField31.setEnabled(true);
        jTextField32.setEnabled(true);
        jTextField33.setEnabled(true);
        jTextField34.setEnabled(true);
        //paswords

        jPasswordField2.setEnabled(true);
        jPasswordField3.setEnabled(true);
        // jPasswordField4.setEnabled(true);

        //privilegios
        jCheckBox14.setSelected(false);
        jCheckBox15.setSelected(false);
        jCheckBox16.setSelected(false);
        jCheckBox17.setSelected(false);
        jCheckBox18.setSelected(false);
        jCheckBox19.setSelected(false);
        jCheckBox20.setSelected(false);
        jCheckBox21.setSelected(false);
        jCheckBox22.setSelected(false);
        jCheckBox23.setSelected(false);
        jCheckBox24.setSelected(false);
        jCheckBox25.setSelected(false);
        jCheckBox26.setSelected(false);

        jCheckBox14.setEnabled(true);
        jCheckBox15.setEnabled(true);
        jCheckBox16.setEnabled(true);
        jCheckBox17.setEnabled(true);
        jCheckBox18.setEnabled(true);
        jCheckBox19.setEnabled(true);
        jCheckBox20.setEnabled(true);
        jCheckBox21.setEnabled(true);
        jCheckBox22.setEnabled(true);
        jCheckBox23.setEnabled(true);
        jCheckBox24.setEnabled(true);
        jCheckBox25.setEnabled(true);
        jCheckBox26.setEnabled(true);

        try {
            Iterator it2 = neg.ListarPrivilegios(jTextField30.getSelectedItem().toString()).iterator();
            while (it2.hasNext()) {
                Usuarios us = (Usuarios) it2.next();

                jTextField32.setText(us.getApePat());
                jTextField33.setText(us.getApeMat());
                jTextField34.setText(us.getNombre());
                jTextField31.setText(us.getCargo());

                jPasswordField2.setText(us.getPass());
                jPasswordField3.setText(us.getPass());

                jCheckBox15.setSelected(us.isCambioSucursal());
                jCheckBox24.setSelected(us.isBonosViaje());
                jCheckBox22.setSelected(us.isAdmin());
                jCheckBox21.setSelected(us.isGuardar());
                jCheckBox26.setSelected(us.isVerbono());
                jCheckBox23.setSelected(us.isVer());
                jCheckBox25.setSelected(us.isLiquiMes());
                jCheckBox18.setSelected(us.isLiquiAño());
                jCheckBox20.setSelected(us.isLiquiTodos());
                jCheckBox19.setSelected(us.isLiquiGerencia());
                jCheckBox17.setSelected(us.isEliminar());
                jCheckBox16.setSelected(us.isEliminarMes());
                jCheckBox14.setSelected(us.isCerrarMes());
            }
        } catch (Exception ex) {
        }

    }//GEN-LAST:event_jbCuModificarActionPerformed

    private void jbcuLimpiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbcuLimpiarActionPerformed
        // TODO add your handling code here:
        this.jlError.setText("");
        op.setText("");
        //botones
        this.jbCuModificar.setEnabled(true);//
        this.jbCuNuevo.setEnabled(true);//
        jbcuEliminar.setEnabled(true);//

        this.jbcuLimpiar.setEnabled(false);//
        this.jbCuGuardar.setEnabled(false);//

        //texto
        jTextField30.removeAllItems();
        jTextField31.setText("");
        jTextField32.setText("");
        jTextField33.setText("");
        jTextField34.setText("");
        //paswords

        jPasswordField2.setText("");
        jPasswordField3.setText("");
        // jPasswordField4.setText("");

        //textoActivar
        jTextField30.setEditable(true);
        jTextField31.setEditable(false);
        jTextField32.setEditable(false);
        jTextField33.setEditable(false);
        jTextField34.setEditable(false);
        //paswords

        jPasswordField2.setEditable(false);
        jPasswordField3.setEditable(false);

        //privilegios
        jCheckBox14.setSelected(false);
        jCheckBox15.setSelected(false);
        jCheckBox16.setSelected(false);
        jCheckBox17.setSelected(false);
        jCheckBox18.setSelected(false);
        jCheckBox19.setSelected(false);
        jCheckBox20.setSelected(false);
        jCheckBox21.setSelected(false);
        jCheckBox22.setSelected(false);
        jCheckBox23.setSelected(false);
        jCheckBox24.setSelected(false);
        jCheckBox25.setSelected(false);
        jCheckBox26.setSelected(false);

        jCheckBox14.setEnabled(false);
        jCheckBox15.setEnabled(false);
        jCheckBox16.setEnabled(false);
        jCheckBox17.setEnabled(false);
        jCheckBox18.setEnabled(false);
        jCheckBox19.setEnabled(false);
        jCheckBox20.setEnabled(false);
        jCheckBox21.setEnabled(false);
        jCheckBox22.setEnabled(false);
        jCheckBox23.setEnabled(false);
        jCheckBox24.setEnabled(false);
        jCheckBox25.setEnabled(false);
        jCheckBox26.setEnabled(false);

        jTextField30.setEnabled(false);
    }//GEN-LAST:event_jbcuLimpiarActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        //logeo correcto
        //botones

        jTextField30.setEnabled(false);

        Iterator it = neg.Seguridad(this.jTextField28.getText(), this.jPasswordField4.getText()).iterator();
        while (it.hasNext()) {
            Usuarios us = (Usuarios) it.next();
            //activacion de uso basico
            //activacion para admin
            if (us.isAdmin()) {

                jbCuModificar.setEnabled(true);//
                jbCuNuevo.setEnabled(true);//
                jbcuEliminar.setEnabled(true);//

                jbcuLimpiar.setEnabled(false);//
                jbCuGuardar.setEnabled(false);//

                jCheckBox14.setSelected(false);
                jCheckBox15.setSelected(false);
                jCheckBox16.setSelected(false);
                jCheckBox17.setSelected(false);
                jCheckBox18.setSelected(false);
                jCheckBox19.setSelected(false);
                jCheckBox20.setSelected(false);
                jCheckBox21.setSelected(false);
                jCheckBox22.setSelected(false);
                jCheckBox23.setSelected(false);
                jCheckBox24.setSelected(false);
                jCheckBox25.setSelected(false);
                jCheckBox26.setSelected(false);

                jPasswordField4.setEditable(false);
                jButton2.setEnabled(false);
            }
        }



    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
        // TODO add your handling code here:
        this.ControlAcceso.setVisible(false);
        this.privilegios();
    }//GEN-LAST:event_jButton9ActionPerformed

    private void jTextField32KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField32KeyTyped
        if (this.jTextField32.getText().trim().length() > 20) {
            evt.consume();
        }
    }//GEN-LAST:event_jTextField32KeyTyped

    private void jTextField33KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField33KeyTyped
        // TODO add your handling code here:
        if (this.jTextField33.getText().trim().length() > 20) {
            evt.consume();
        }
    }//GEN-LAST:event_jTextField33KeyTyped

    private void jTextField34KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField34KeyTyped
        // TODO add your handling code here:
        if (this.jTextField34.getText().trim().length() > 20) {
            evt.consume();
        }
    }//GEN-LAST:event_jTextField34KeyTyped

    private void jTextField31KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField31KeyTyped
        if (this.jTextField31.getText().trim().length() > 35) {
            evt.consume();
        }
    }//GEN-LAST:event_jTextField31KeyTyped

    private void jPasswordField2KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jPasswordField2KeyTyped
        // TODO add your handling code here:
        if (this.jPasswordField2.getText().trim().length() > 6) {
            evt.consume();
        }
    }//GEN-LAST:event_jPasswordField2KeyTyped

    private void jPasswordField3KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jPasswordField3KeyTyped
        // TODO add your handling code here:
        if (this.jPasswordField3.getText().trim().length() > 6) {
            evt.consume();
        }
    }//GEN-LAST:event_jPasswordField3KeyTyped

    private void jPasswordField3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jPasswordField3ActionPerformed
        // TODO add your handling code here:
        if (this.jPasswordField3.getText().trim().equalsIgnoreCase(jPasswordField2.getText().trim())) {
        } else {
            this.jlError.setText("Contraseñas no son iguales");

        }
    }//GEN-LAST:event_jPasswordField3ActionPerformed

    private void jTextField30MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTextField30MouseReleased
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField30MouseReleased

    private void jTextField30MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTextField30MouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField30MouseClicked

    private void jTextField30MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTextField30MousePressed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField30MousePressed

    private void jTextField30ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField30ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField30ActionPerformed

    private void jTextField30ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jTextField30ItemStateChanged
        // TODO add your handling code here:
        try {
            Iterator it2 = neg.ListarPrivilegios(jTextField30.getSelectedItem().toString()).iterator();
            while (it2.hasNext()) {
                Usuarios us = (Usuarios) it2.next();

                jTextField32.setText(us.getApePat());
                jTextField33.setText(us.getApeMat());
                jTextField34.setText(us.getNombre());
                jTextField31.setText(us.getCargo());

                jPasswordField2.setText(us.getPass());
                jPasswordField3.setText(us.getPass());

                jCheckBox15.setSelected(us.isCambioSucursal());
                jCheckBox24.setSelected(us.isBonosViaje());
                jCheckBox22.setSelected(us.isAdmin());
                jCheckBox21.setSelected(us.isGuardar());
                jCheckBox26.setSelected(us.isVerbono());
                jCheckBox23.setSelected(us.isVer());
                jCheckBox25.setSelected(us.isLiquiMes());
                jCheckBox18.setSelected(us.isLiquiAño());
                jCheckBox20.setSelected(us.isLiquiTodos());
                jCheckBox19.setSelected(us.isLiquiGerencia());
                jCheckBox17.setSelected(us.isEliminar());
                jCheckBox16.setSelected(us.isEliminarMes());
                jCheckBox14.setSelected(us.isCerrarMes());
            }
        } catch (Exception ex) {
        }
    }//GEN-LAST:event_jTextField30ItemStateChanged

    private void jPasswordField3FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jPasswordField3FocusLost
        // TODO add your handling code here:
        if (this.jPasswordField3.getText().trim().equalsIgnoreCase(jPasswordField2.getText().trim())) {
        } else {
            this.jlError.setText("Contraseñas no son iguales");
        }
    }//GEN-LAST:event_jPasswordField3FocusLost

    private void jbcuEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbcuEliminarActionPerformed
        // TODO add your handling code here:
        this.jlError.setText("");
        op.setText("eliminar");
        Iterator user = neg.ListarUser().iterator();

        while (user.hasNext()) {
            Usuarios us = (Usuarios) user.next();

            jTextField30.addItem(us.getUsuario());

        }
        //botones
        this.jbCuModificar.setEnabled(false);//
        this.jbCuNuevo.setEnabled(false);//
        jbcuEliminar.setEnabled(false);//

        this.jbcuLimpiar.setEnabled(true);//
        this.jbCuGuardar.setEnabled(true);//

        //texto

        jTextField31.setText("");
        jTextField32.setText("");
        jTextField33.setText("");
        jTextField34.setText("");
        //paswords

        jPasswordField2.setText("");
        jPasswordField3.setText("");
        // jPasswordField4.setText("");

        //textoActivar
        jTextField30.setEditable(false);
        jTextField31.setEditable(false);
        jTextField32.setEditable(false);
        jTextField33.setEditable(false);
        jTextField34.setEditable(false);
        //paswords

        jPasswordField2.setEditable(false);
        jPasswordField3.setEditable(false);


        //privilegios
        jCheckBox14.setSelected(false);
        jCheckBox15.setSelected(false);
        jCheckBox16.setSelected(false);
        jCheckBox17.setSelected(false);
        jCheckBox18.setSelected(false);
        jCheckBox19.setSelected(false);
        jCheckBox20.setSelected(false);
        jCheckBox21.setSelected(false);
        jCheckBox22.setSelected(false);
        jCheckBox23.setSelected(false);
        jCheckBox24.setSelected(false);
        jCheckBox25.setSelected(false);
        jCheckBox26.setSelected(false);

        jCheckBox14.setEnabled(false);
        jCheckBox15.setEnabled(false);
        jCheckBox16.setEnabled(false);
        jCheckBox17.setEnabled(false);
        jCheckBox18.setEnabled(false);
        jCheckBox19.setEnabled(false);
        jCheckBox20.setEnabled(false);
        jCheckBox21.setEnabled(false);
        jCheckBox22.setEnabled(false);
        jCheckBox23.setEnabled(false);
        jCheckBox24.setEnabled(false);
        jCheckBox25.setEnabled(false);
        jCheckBox26.setEnabled(false);
        jTextField30.setEnabled(true);
    }//GEN-LAST:event_jbcuEliminarActionPerformed

    private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed
        // TODO add your handling code here:
        this.jfSucursales.setVisible(false);
    }//GEN-LAST:event_jButton11ActionPerformed

    private void jtfRetenciSanAntonioKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfRetenciSanAntonioKeyTyped
        // TODO add your handling code here:
        char letra = evt.getKeyChar();

        if (letra < '0' || letra > '9') {
            evt.consume();
        } else {
            if (this.jtfRetenciSanAntonio.getText().trim().length() > 1) {
                evt.consume();
            }
        }
    }//GEN-LAST:event_jtfRetenciSanAntonioKeyTyped

    private void jtfPartciSanAntonioKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfPartciSanAntonioKeyTyped
        // TODO add your handling code here:
        char letra = evt.getKeyChar();

        if (letra < '0' || letra > '9') {
            evt.consume();
        } else {
            if (this.jtfPartciSanAntonio.getText().trim().length() > 1) {
                evt.consume();
            }
        }
    }//GEN-LAST:event_jtfPartciSanAntonioKeyTyped

    private void jTextField26KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField26KeyTyped
        // TODO add your handling code here:
        char letra = evt.getKeyChar();

        if (letra < '0' || letra > '9') {
            evt.consume();
        } else {
            if (this.jTextField26.getText().trim().length() > 1) {
                evt.consume();
            }
        }
    }//GEN-LAST:event_jTextField26KeyTyped

    private void jTextField29KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField29KeyTyped
        // TODO add your handling code here:
        char letra = evt.getKeyChar();

        if (letra < '0' || letra > '9') {
            evt.consume();
        } else {
            if (this.jTextField29.getText().trim().length() > 1) {
                evt.consume();
            }
        }
    }//GEN-LAST:event_jTextField29KeyTyped

    private void jTextField35KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField35KeyTyped
        // TODO add your handling code here:
        char letra = evt.getKeyChar();

        if (letra < '0' || letra > '9') {
            evt.consume();
        } else {
            if (this.jTextField35.getText().trim().length() > 1) {
                evt.consume();
            }
        }
    }//GEN-LAST:event_jTextField35KeyTyped

    private void jTextField36KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField36KeyTyped
        // TODO add your handling code here:
        char letra = evt.getKeyChar();

        if (letra < '0' || letra > '9') {
            evt.consume();
        } else {
            if (this.jTextField36.getText().trim().length() > 1) {
                evt.consume();
            }
        }
    }//GEN-LAST:event_jTextField36KeyTyped

    private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
        // TODO add your handling code here:
        if (jTextField36.getText().isEmpty()) {
            jLabelPorcentSanAntonio.setText("Ingrese Retencion");
        } else {
            if (jTextField35.getText().isEmpty()) {
                jLabelPorcentSanAntonio.setText("Ingrese Participacion");
            } else {
                //guradar nuevos datos
                Sucursales suc = new Sucursales();
                NegocioInsert ni = new NegocioInsert();

                suc.setSucursales("Manuel Montt");
                suc.setParticipacion(Integer.parseInt(jTextField36.getText()));
                suc.setRetencion(Integer.parseInt(jTextField35.getText()));

                ni.ModificarSucursal(suc);
                jLabelPorcentSanAntonio.setText("");
            }
        }
    }//GEN-LAST:event_jButton10ActionPerformed

    private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton12ActionPerformed
        // TODO add your handling code here:
        if (jTextField26.getText().isEmpty()) {
            jLabelPorcentSanAntonio.setText("Ingrese Retencion");
        } else {
            if (jTextField29.getText().isEmpty()) {
                jLabelPorcentSanAntonio.setText("Ingrese Participacion");
            } else {
                //guradar nuevos datos
                Sucursales suc = new Sucursales();
                NegocioInsert ni = new NegocioInsert();

                suc.setSucursales("Bandera");
                suc.setParticipacion(Integer.parseInt(jTextField29.getText()));
                suc.setRetencion(Integer.parseInt(jTextField26.getText()));

                ni.ModificarSucursal(suc);
                jLabelPorcentSanAntonio.setText("");
            }
        }
    }//GEN-LAST:event_jButton12ActionPerformed

    private void jButton14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton14ActionPerformed
        // TODO add your handling code here:
        if (jtfRetenciSanAntonio.getText().isEmpty()) {
            jLabelPorcentSanAntonio.setText("Ingrese Retencion");
        } else {
            if (jtfPartciSanAntonio.getText().isEmpty()) {
                jLabelPorcentSanAntonio.setText("Ingrese Participacion");
            } else {
                //guradar nuevos datos
                Sucursales suc = new Sucursales();
                NegocioInsert ni = new NegocioInsert();

                suc.setSucursales("San Antonio");
                suc.setParticipacion(Integer.parseInt(jtfPartciSanAntonio.getText()));
                suc.setRetencion(Integer.parseInt(jtfRetenciSanAntonio.getText()));

                ni.ModificarSucursal(suc);
                jLabelPorcentSanAntonio.setText("");
            }
        }
    }//GEN-LAST:event_jButton14ActionPerformed

    private void jbtMantSucPorcentajeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtMantSucPorcentajeActionPerformed
        // TODO add your handling code here:
        jfSucursales.setVisible(true);
        jfSucursales.pack();
        jfSucursales.setAlwaysOnTop(true);
        jfSucursales.setLocation(200, 70);
        jLabelPorcentSanAntonio.setText("");

        Iterator it = neg.ListarSucursales().iterator();
        while (it.hasNext()) {
            Sucursales su = (Sucursales) it.next();

            if (su.getSucursales().equalsIgnoreCase("San Antonio")) {
                jtfRetenciSanAntonio.setText("" + su.getRetencion());
                jtfPartciSanAntonio.setText("" + su.getParticipacion());
            }
            if (su.getSucursales().equalsIgnoreCase("Bandera")) {
                jTextField26.setText("" + su.getRetencion());
                jTextField29.setText("" + su.getParticipacion());
            }
            if (su.getSucursales().equalsIgnoreCase("Manuel Montt")) {
                jTextField35.setText("" + su.getRetencion());
                jTextField36.setText("" + su.getParticipacion());
            }
            if (su.getSucursales().equalsIgnoreCase("La Florida")) {
                jtfRetencionLaFlorida.setText("" + su.getRetencion());
                jtfPartiLaFlorida.setText("" + su.getParticipacion());
            }
        }
    }//GEN-LAST:event_jbtMantSucPorcentajeActionPerformed

    private void jbtSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtSalirActionPerformed
        salir();
    }//GEN-LAST:event_jbtSalirActionPerformed

    private void jPasswordField4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jPasswordField4ActionPerformed
        // TODO add your handling code here:
        jTextField30.setEnabled(false);
        this.jbCuNuevo.requestFocus();
        Iterator it = neg.Seguridad(this.jTextField28.getText(), this.jPasswordField4.getText()).iterator();
        while (it.hasNext()) {
            Usuarios us = (Usuarios) it.next();
            //activacion de uso basico
            //activacion para admin
            if (us.isAdmin()) {

                jbCuModificar.setEnabled(true);//
                jbCuNuevo.setEnabled(true);//
                jbcuEliminar.setEnabled(true);

                jbcuLimpiar.setEnabled(false);//
                jbCuGuardar.setEnabled(false);//

                jCheckBox14.setSelected(false);
                jCheckBox15.setSelected(false);
                jCheckBox16.setSelected(false);
                jCheckBox17.setSelected(false);
                jCheckBox18.setSelected(false);
                jCheckBox19.setSelected(false);
                jCheckBox20.setSelected(false);
                jCheckBox21.setSelected(false);
                jCheckBox22.setSelected(false);
                jCheckBox23.setSelected(false);
                jCheckBox24.setSelected(false);
                jCheckBox25.setSelected(false);
                jCheckBox26.setSelected(false);

                jPasswordField4.setEditable(false);
                jButton2.setEnabled(false);
            }
        }
    }//GEN-LAST:event_jPasswordField4ActionPerformed

    private void jtAccessMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jtAccessMouseReleased
        this.buscaPresu();
    }//GEN-LAST:event_jtAccessMouseReleased

    private void jtxtUserFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jtxtUserFocusLost
        // TODO add your handling code here:
        jtxtUser.setText(jtxtUser.getText().toUpperCase());
        //   this.jtxtPass.requestFocus();
    }//GEN-LAST:event_jtxtUserFocusLost

    private void jTextField32ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField32ActionPerformed
        // TODO add your handling code here:
        jTextField32.setText(jTextField32.getText().toUpperCase());
        jTextField33.requestFocus();
    }//GEN-LAST:event_jTextField32ActionPerformed

    private void jTextField33ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField33ActionPerformed
        // TODO add your handling code here:
        jTextField33.setText(jTextField33.getText().toUpperCase());
        jTextField34.requestFocus();
    }//GEN-LAST:event_jTextField33ActionPerformed

    private void jTextField32FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField32FocusLost
        // TODO add your handling code here:
        jTextField32.setText(jTextField32.getText().toUpperCase());
    }//GEN-LAST:event_jTextField32FocusLost

    private void jTextField33FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField33FocusLost
        // TODO add your handling code here:
        jTextField33.setText(jTextField33.getText().toUpperCase());
    }//GEN-LAST:event_jTextField33FocusLost

    private void jTextField34ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField34ActionPerformed
        // TODO add your handling code here:
        jTextField34.setText(jTextField34.getText().toUpperCase());
        jTextField31.requestFocus();
    }//GEN-LAST:event_jTextField34ActionPerformed

    private void jTextField34FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField34FocusLost
        // TODO add your handling code here:
        jTextField34.setText(jTextField34.getText().toUpperCase());
    }//GEN-LAST:event_jTextField34FocusLost

    private void jTextField31ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField31ActionPerformed
        // TODO add your handling code here:
        jTextField31.setText(jTextField31.getText().toUpperCase());
    }//GEN-LAST:event_jTextField31ActionPerformed

    private void jTextField31FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField31FocusLost
        // TODO add your handling code here:
        jTextField31.setText(jTextField31.getText().toUpperCase());
    }//GEN-LAST:event_jTextField31FocusLost

    private void jbtLaFloridaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtLaFloridaActionPerformed
        // TODO add your handling code here:
        
        jtxtPresupuesto.setText("");
        jtxtValorPresupuesto.setText("");
        jtOracle.setVisible(false);
        jbtGuardar.setEnabled(false);
        jtxtPago.setEnabled(false);
        jcbLaboratorio.setEditable(false);
        jtxtRayos.setEditable(false);
        jcboDoctor.setSelectedIndex(0);
        jtxtPaciente.setText("");
        jcboDoctor.setSelectedIndex(0);
        jcDetalle.removeAllItems();
        jcDetalle.addItem("Detalle del Pago");

        FileWriter fichero = null;
        PrintWriter pw = null;
        try {
            // asigno nombre de fichero, mantengo la nomenclatura
            fichero = new FileWriter("C:\\WINDOWS\\system32\\xmlj.ini");
            // asigno PrintWriter a fichero
            pw = new PrintWriter(fichero);

            // escribo los parametros
            pw.println("[Sucursales]");

            pw.println("Sucursal = 5");
            pw.println("CambioSucursal = true");
            pw.println("funcionar = wizard");

            // vuelco la memoria al disco duro
            pw.flush(); // cierro los canales de escritura
            fichero.close();
            pw.close();
        } catch (Exception EX) {
            System.out.println("EROOR!!!!!" + EX);
        }
        ValidaSucursal();
    }//GEN-LAST:event_jbtLaFloridaActionPerformed

    private void jtfRetencionLaFloridaKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfRetencionLaFloridaKeyTyped
        // TODO add your handling code here:
    }//GEN-LAST:event_jtfRetencionLaFloridaKeyTyped

    private void jtfPartiLaFloridaKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfPartiLaFloridaKeyTyped
        // TODO add your handling code here:
    }//GEN-LAST:event_jtfPartiLaFloridaKeyTyped

    private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton13ActionPerformed
        // TODO add your handling code here:
                if (jTextField36.getText().isEmpty()) {
            jLabelPorcentSanAntonio.setText("Ingrese Retencion");
        } else {
            if (jTextField35.getText().isEmpty()) {
                jLabelPorcentSanAntonio.setText("Ingrese Participacion");
            } else {
                //guradar nuevos datos
                Sucursales suc = new Sucursales();
                NegocioInsert ni = new NegocioInsert();

                suc.setSucursales("La Florida");
                suc.setParticipacion(Integer.parseInt(this.jtfPartiLaFlorida.getText()));
                suc.setRetencion(Integer.parseInt(this.jtfRetencionLaFlorida.getText()));

                ni.ModificarSucursal(suc);
                jLabelPorcentSanAntonio.setText("");
            }
        }
    }//GEN-LAST:event_jButton13ActionPerformed

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                try {
                    new GUI1().setVisible(true);
                } catch (IOException ex) {
                    Logger.getLogger(GUI1.class.getName()).log(Level.SEVERE, null, ex);
                }

            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JFrame Activar;
    private javax.swing.JFrame ActivarMes;
    private javax.swing.JLayeredPane Admin;
    private javax.swing.JLayeredPane Bonos;
    private javax.swing.JLayeredPane CerrarMes;
    private javax.swing.JFrame ControlAcceso;
    private javax.swing.JLayeredPane Creditos;
    private javax.swing.JLayeredPane Informes;
    private javax.swing.JLayeredPane IngUsuario;
    private javax.swing.JLayeredPane Ingresar;
    private javax.swing.JLayeredPane Sucursales;
    private javax.swing.JButton jBtLogin;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton12;
    private javax.swing.JButton jButton13;
    private javax.swing.JButton jButton14;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton9;
    private javax.swing.JCheckBox jCheckBox14;
    private javax.swing.JCheckBox jCheckBox15;
    private javax.swing.JCheckBox jCheckBox16;
    private javax.swing.JCheckBox jCheckBox17;
    private javax.swing.JCheckBox jCheckBox18;
    private javax.swing.JCheckBox jCheckBox19;
    private javax.swing.JCheckBox jCheckBox20;
    private javax.swing.JCheckBox jCheckBox21;
    private javax.swing.JCheckBox jCheckBox22;
    private javax.swing.JCheckBox jCheckBox23;
    private javax.swing.JCheckBox jCheckBox24;
    private javax.swing.JCheckBox jCheckBox25;
    private javax.swing.JCheckBox jCheckBox26;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JComboBox jComboBox3;
    private javax.swing.JComboBox jComboBox4;
    private javax.swing.JComboBox jComboBox5;
    private javax.swing.JComboBox jComboBox6;
    private javax.swing.JComboBox jComboBox7;
    private javax.swing.JComboBox jComboBox8;
    private javax.swing.JComboBox jComboBox9;
    private javax.swing.JLabel jLFecha;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel31;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel33;
    private javax.swing.JLabel jLabel34;
    private javax.swing.JLabel jLabel37;
    private javax.swing.JLabel jLabel38;
    private javax.swing.JLabel jLabel39;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel40;
    private javax.swing.JLabel jLabel41;
    private javax.swing.JLabel jLabel42;
    private javax.swing.JLabel jLabel43;
    private javax.swing.JLabel jLabel44;
    private javax.swing.JLabel jLabel45;
    private javax.swing.JLabel jLabel46;
    private javax.swing.JLabel jLabel47;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel50;
    private javax.swing.JLabel jLabel51;
    private javax.swing.JLabel jLabel52;
    private javax.swing.JLabel jLabel53;
    private javax.swing.JLabel jLabel54;
    private javax.swing.JLabel jLabel55;
    private javax.swing.JLabel jLabel57;
    private javax.swing.JLabel jLabel58;
    private javax.swing.JLabel jLabel59;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel60;
    private javax.swing.JLabel jLabel61;
    private javax.swing.JLabel jLabel62;
    private javax.swing.JLabel jLabel63;
    private javax.swing.JLabel jLabel64;
    private javax.swing.JLabel jLabel66;
    private javax.swing.JLabel jLabel67;
    private javax.swing.JLabel jLabel68;
    private javax.swing.JLabel jLabel69;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel70;
    private javax.swing.JLabel jLabel71;
    private javax.swing.JLabel jLabel72;
    private javax.swing.JLabel jLabel73;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel jLabelCreador;
    private javax.swing.JLabel jLabelPorcentBandera;
    private javax.swing.JLabel jLabelPorcentLaFlorida;
    private javax.swing.JLabel jLabelPorcentManuelMontt;
    private javax.swing.JLabel jLabelPorcentSanAntonio;
    private javax.swing.JLabel jLabelSucursalAdmin;
    private javax.swing.JLabel jLabelSucursalInformes;
    private javax.swing.JLabel jLbUser;
    private javax.swing.JPasswordField jPasswordField1;
    private javax.swing.JPasswordField jPasswordField2;
    private javax.swing.JPasswordField jPasswordField3;
    private javax.swing.JPasswordField jPasswordField4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator11;
    private javax.swing.JSeparator jSeparator12;
    private javax.swing.JSeparator jSeparator13;
    private javax.swing.JSeparator jSeparator14;
    private javax.swing.JSeparator jSeparator15;
    private javax.swing.JSeparator jSeparator16;
    private javax.swing.JSeparator jSeparator17;
    private javax.swing.JSeparator jSeparator18;
    private javax.swing.JSeparator jSeparator19;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator20;
    private javax.swing.JSeparator jSeparator21;
    private javax.swing.JSeparator jSeparator22;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JSeparator jSeparator5;
    private javax.swing.JSeparator jSeparator6;
    private javax.swing.JSeparator jSeparator7;
    private javax.swing.JSeparator jSeparator8;
    private javax.swing.JSpinner jSpinner1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTabbedPane jTabbedPane2;
    private javax.swing.JTable jTbuscarDoctor;
    private javax.swing.JTable jTbuscarDoctor1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JSpinner jTextField10;
    private javax.swing.JSpinner jTextField11;
    private javax.swing.JSpinner jTextField12;
    private javax.swing.JSpinner jTextField14;
    private javax.swing.JTextField jTextField15;
    private javax.swing.JTextField jTextField16;
    private javax.swing.JTextField jTextField17;
    private javax.swing.JTextField jTextField18;
    private javax.swing.JTextField jTextField19;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField20;
    private javax.swing.JTextField jTextField21;
    private javax.swing.JTextField jTextField22;
    private javax.swing.JTextField jTextField23;
    private javax.swing.JTextField jTextField24;
    private javax.swing.JTextField jTextField26;
    private javax.swing.JTextField jTextField27;
    private javax.swing.JTextField jTextField28;
    private javax.swing.JTextField jTextField29;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JComboBox jTextField30;
    private javax.swing.JTextField jTextField31;
    private javax.swing.JTextField jTextField32;
    private javax.swing.JTextField jTextField33;
    private javax.swing.JTextField jTextField34;
    private javax.swing.JTextField jTextField35;
    private javax.swing.JTextField jTextField36;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JTextField jTextField6;
    private javax.swing.JSpinner jTextField7;
    private javax.swing.JSpinner jTextField9;
    private javax.swing.JTextPane jTextPane1;
    private javax.swing.JButton jbCuGuardar;
    private javax.swing.JButton jbCuModificar;
    private javax.swing.JButton jbCuNuevo;
    private javax.swing.JButton jbcuEliminar;
    private javax.swing.JButton jbcuLimpiar;
    private javax.swing.JButton jbtBandera;
    private javax.swing.JButton jbtBuscarDoctor;
    private javax.swing.JButton jbtBuscarDoctor1;
    private javax.swing.JButton jbtConfig;
    private javax.swing.JButton jbtExExcelDr;
    private javax.swing.JButton jbtExExcelDr1;
    private javax.swing.JButton jbtExExcelDr2;
    private javax.swing.JButton jbtExExcelDr3;
    private javax.swing.JButton jbtGuardar;
    private javax.swing.JButton jbtGuardarBono;
    private javax.swing.JButton jbtLaFlorida;
    private javax.swing.JButton jbtManUser;
    private javax.swing.JButton jbtMantSucPorcentaje;
    private javax.swing.JButton jbtMontt;
    private javax.swing.JButton jbtSalir;
    private javax.swing.JButton jbtSanAntonio;
    private javax.swing.JButton jbtVerBono;
    private javax.swing.JComboBox jcDetalle;
    private javax.swing.JComboBox jcbCerrar_mes;
    private javax.swing.JComboBox jcbInfo_Odon1;
    private javax.swing.JComboBox jcbInfo_Odon2;
    private javax.swing.JTextField jcbLaboratorio;
    private javax.swing.JComboBox jcboDoctor;
    private javax.swing.JComboBox jcboDoctorBuscar;
    private javax.swing.JComboBox jcboDoctorBuscar1;
    private javax.swing.JComboBox jcboFecha;
    private javax.swing.JComboBox jcboFecha1;
    private javax.swing.JComboBox jcboFechaIngreso;
    private javax.swing.JFrame jfSucursales;
    private javax.swing.JLabel jlError;
    private javax.swing.JLabel jlOcultarIngreso;
    private javax.swing.JLabel jlbBackgroundLogin;
    private javax.swing.JLabel jlbCerrar_sucursal;
    private javax.swing.JLabel jlbCodigo;
    private javax.swing.JLabel jlbDr;
    private javax.swing.JLabel jlbLaboratorio;
    private javax.swing.JLabel jlbLaboratorio1;
    private javax.swing.JLabel jlbPaciente;
    private javax.swing.JLabel jlbPago;
    private javax.swing.JLabel jlbPass;
    private javax.swing.JTable jtAccess;
    private javax.swing.JTable jtOracle;
    private javax.swing.JButton jtbActivarMeses;
    private javax.swing.JTextField jtfPartciSanAntonio;
    private javax.swing.JTextField jtfPartiLaFlorida;
    private javax.swing.JTextField jtfRetenciSanAntonio;
    private javax.swing.JTextField jtfRetencionLaFlorida;
    private javax.swing.JTable jtverBonos;
    private javax.swing.JSpinner jtxtAño;
    private javax.swing.JTextField jtxtAño1;
    private javax.swing.JSpinner jtxtAñoBono;
    private javax.swing.JTextField jtxtBoleta;
    private javax.swing.JSpinner jtxtCerrar_Año;
    private javax.swing.JTextField jtxtPaciente;
    private javax.swing.JTextField jtxtPago;
    private javax.swing.JPasswordField jtxtPass;
    private javax.swing.JTextField jtxtPresupuesto;
    private javax.swing.JTextField jtxtRayos;
    private javax.swing.JTextField jtxtTotalLab;
    private javax.swing.JTextField jtxtTotalPagado;
    private javax.swing.JTextField jtxtUser;
    private javax.swing.JTextField jtxtValorPresupuesto;
    private javax.swing.JLabel op;
    private javax.swing.JLayeredPane ver;
    private javax.swing.JLayeredPane ver1;
    // End of variables declaration//GEN-END:variables
    DecimalFormat df = new DecimalFormat("$ #,###");

    public void Fecha() {

        String FechaMes = formato.format(fechaActual).substring(4, 6);
//
//        jtxtAño.setValue("" + FechaAño);
//        jTextField7.setValue("" + FechaAño);
//        jSpinner1.setValue("" + FechaAño);
//        jtxtCerrar_Año.setValue("" + FechaAño);
//        jTextField9.setValue("" + FechaAño);
//        jTextField10.setValue("" + FechaAño);
////        jTextField11.setValue("2013"+FechaAño);
////        jTextField14.setValue("2013");

        jcboFecha.removeAllItems();

        for (int a = 0; a <= 11; a++) {
            this.jcboFecha.addItem(Mes[a]);
        }
        if (FechaMes.equalsIgnoreCase("01")) {
            this.jcboFecha.setSelectedItem(Mes[0]);
        }
        if (FechaMes.equalsIgnoreCase("02")) {
            this.jcboFecha.setSelectedItem(Mes[1]);
        }
        if (FechaMes.equalsIgnoreCase("03")) {
            this.jcboFecha.setSelectedItem(Mes[2]);
        }
        if (FechaMes.equalsIgnoreCase("04")) {
            this.jcboFecha.setSelectedItem(Mes[3]);
        }
        if (FechaMes.equalsIgnoreCase("05")) {
            this.jcboFecha.setSelectedItem(Mes[4]);
        }
        if (FechaMes.equalsIgnoreCase("06")) {
            this.jcboFecha.setSelectedItem(Mes[5]);
        }
        if (FechaMes.equalsIgnoreCase("07")) {
            this.jcboFecha.setSelectedItem(Mes[6]);
        }
        if (FechaMes.equalsIgnoreCase("08")) {
            this.jcboFecha.setSelectedItem(Mes[7]);
        }
        if (FechaMes.equalsIgnoreCase("09")) {
            this.jcboFecha.setSelectedItem(Mes[8]);
        }
        if (FechaMes.equalsIgnoreCase("10")) {
            this.jcboFecha.setSelectedItem(Mes[9]);
        }
        if (FechaMes.equalsIgnoreCase("11")) {
            this.jcboFecha.setSelectedItem(Mes[10]);
        }
        if (FechaMes.equalsIgnoreCase("12")) {
            this.jcboFecha.setSelectedItem(Mes[11]);
        }
////////////////////////////////////////////////////////////////
        this.jcboFechaIngreso.removeAllItems();
        for (int a = 0; a <= 11; a++) {
            this.jcboFechaIngreso.addItem(Mes[a]);
        }
        if (FechaMes.equalsIgnoreCase("01")) {
            this.jcboFechaIngreso.setSelectedItem(Mes[0]);
        }
        if (FechaMes.equalsIgnoreCase("02")) {
            this.jcboFechaIngreso.setSelectedItem(Mes[1]);
        }
        if (FechaMes.equalsIgnoreCase("03")) {
            this.jcboFechaIngreso.setSelectedItem(Mes[2]);
        }
        if (FechaMes.equalsIgnoreCase("04")) {
            this.jcboFechaIngreso.setSelectedItem(Mes[3]);
        }
        if (FechaMes.equalsIgnoreCase("05")) {
            this.jcboFechaIngreso.setSelectedItem(Mes[4]);
        }
        if (FechaMes.equalsIgnoreCase("06")) {
            this.jcboFechaIngreso.setSelectedItem(Mes[5]);
        }
        if (FechaMes.equalsIgnoreCase("07")) {
            this.jcboFechaIngreso.setSelectedItem(Mes[6]);
        }
        if (FechaMes.equalsIgnoreCase("08")) {
            this.jcboFechaIngreso.setSelectedItem(Mes[7]);
        }
        if (FechaMes.equalsIgnoreCase("09")) {
            this.jcboFechaIngreso.setSelectedItem(Mes[8]);
        }
        if (FechaMes.equalsIgnoreCase("10")) {
            this.jcboFechaIngreso.setSelectedItem(Mes[9]);
        }
        if (FechaMes.equalsIgnoreCase("11")) {
            this.jcboFechaIngreso.setSelectedItem(Mes[10]);
        }
        if (FechaMes.equalsIgnoreCase("12")) {
            this.jcboFechaIngreso.setSelectedItem(Mes[11]);
        }
        ///////////////////////////////////////////////////

        this.jComboBox4.removeAllItems();
        for (int a = 0; a <= 11; a++) {
            this.jComboBox4.addItem(Mes[a]);
        }
        if (FechaMes.equalsIgnoreCase("01")) {
            this.jComboBox4.setSelectedItem(Mes[0]);
        }
        if (FechaMes.equalsIgnoreCase("02")) {
            this.jComboBox4.setSelectedItem(Mes[1]);
        }
        if (FechaMes.equalsIgnoreCase("03")) {
            this.jComboBox4.setSelectedItem(Mes[2]);
        }
        if (FechaMes.equalsIgnoreCase("04")) {
            this.jComboBox4.setSelectedItem(Mes[3]);
        }
        if (FechaMes.equalsIgnoreCase("05")) {
            this.jComboBox4.setSelectedItem(Mes[4]);
        }
        if (FechaMes.equalsIgnoreCase("06")) {
            this.jComboBox4.setSelectedItem(Mes[5]);
        }
        if (FechaMes.equalsIgnoreCase("07")) {
            this.jComboBox4.setSelectedItem(Mes[6]);
        }
        if (FechaMes.equalsIgnoreCase("08")) {
            this.jComboBox4.setSelectedItem(Mes[7]);
        }
        if (FechaMes.equalsIgnoreCase("09")) {
            this.jComboBox4.setSelectedItem(Mes[8]);
        }
        if (FechaMes.equalsIgnoreCase("10")) {
            this.jComboBox4.setSelectedItem(Mes[9]);
        }
        if (FechaMes.equalsIgnoreCase("11")) {
            this.jComboBox4.setSelectedItem(Mes[10]);
        }
        if (FechaMes.equalsIgnoreCase("12")) {
            this.jComboBox4.setSelectedItem(Mes[11]);
        }
        //////////////////////////////////////////////////
        this.jComboBox3.removeAllItems();
        for (int a = 0; a <= 11; a++) {
            this.jComboBox3.addItem(Mes[a]);
        }
        if (FechaMes.equalsIgnoreCase("01")) {
            this.jComboBox3.setSelectedItem(Mes[0]);
        }
        if (FechaMes.equalsIgnoreCase("02")) {
            this.jComboBox3.setSelectedItem(Mes[1]);
        }
        if (FechaMes.equalsIgnoreCase("03")) {
            this.jComboBox3.setSelectedItem(Mes[2]);
        }
        if (FechaMes.equalsIgnoreCase("04")) {
            this.jComboBox3.setSelectedItem(Mes[3]);
        }
        if (FechaMes.equalsIgnoreCase("05")) {
            this.jComboBox3.setSelectedItem(Mes[4]);
        }
        if (FechaMes.equalsIgnoreCase("06")) {
            this.jComboBox3.setSelectedItem(Mes[5]);
        }
        if (FechaMes.equalsIgnoreCase("07")) {
            this.jComboBox3.setSelectedItem(Mes[6]);
        }
        if (FechaMes.equalsIgnoreCase("08")) {
            this.jComboBox3.setSelectedItem(Mes[7]);
        }
        if (FechaMes.equalsIgnoreCase("09")) {
            this.jComboBox3.setSelectedItem(Mes[8]);
        }
        if (FechaMes.equalsIgnoreCase("10")) {
            this.jComboBox3.setSelectedItem(Mes[9]);
        }
        if (FechaMes.equalsIgnoreCase("11")) {
            this.jComboBox3.setSelectedItem(Mes[10]);
        }
        if (FechaMes.equalsIgnoreCase("12")) {
            this.jComboBox3.setSelectedItem(Mes[11]);
        }
        //////////////////////////////////////jComboBox6
        this.jComboBox6.removeAllItems();
        for (int a = 0; a <= 11; a++) {
            this.jComboBox6.addItem(Mes[a]);
        }
        if (FechaMes.equalsIgnoreCase("01")) {
            this.jComboBox6.setSelectedItem(Mes[0]);
        }
        if (FechaMes.equalsIgnoreCase("02")) {
            this.jComboBox6.setSelectedItem(Mes[1]);
        }
        if (FechaMes.equalsIgnoreCase("03")) {
            this.jComboBox6.setSelectedItem(Mes[2]);
        }
        if (FechaMes.equalsIgnoreCase("04")) {
            this.jComboBox6.setSelectedItem(Mes[3]);
        }
        if (FechaMes.equalsIgnoreCase("05")) {
            this.jComboBox6.setSelectedItem(Mes[4]);
        }
        if (FechaMes.equalsIgnoreCase("06")) {
            this.jComboBox6.setSelectedItem(Mes[5]);
        }
        if (FechaMes.equalsIgnoreCase("07")) {
            this.jComboBox6.setSelectedItem(Mes[6]);
        }
        if (FechaMes.equalsIgnoreCase("08")) {
            this.jComboBox6.setSelectedItem(Mes[7]);
        }
        if (FechaMes.equalsIgnoreCase("09")) {
            this.jComboBox6.setSelectedItem(Mes[8]);
        }
        if (FechaMes.equalsIgnoreCase("10")) {
            this.jComboBox6.setSelectedItem(Mes[9]);
        }
        if (FechaMes.equalsIgnoreCase("11")) {
            this.jComboBox6.setSelectedItem(Mes[10]);
        }
        if (FechaMes.equalsIgnoreCase("12")) {
            this.jComboBox6.setSelectedItem(Mes[11]);
        }
        //////////////////////////////////////jComboBox6
        this.jcbCerrar_mes.removeAllItems();
        for (int a = 0; a <= 11; a++) {
            this.jcbCerrar_mes.addItem(Mes[a]);
        }
        if (FechaMes.equalsIgnoreCase("01")) {
            this.jcbCerrar_mes.setSelectedItem(Mes[0]);
        }
        if (FechaMes.equalsIgnoreCase("02")) {
            this.jcbCerrar_mes.setSelectedItem(Mes[1]);
        }
        if (FechaMes.equalsIgnoreCase("03")) {
            this.jcbCerrar_mes.setSelectedItem(Mes[2]);
        }
        if (FechaMes.equalsIgnoreCase("04")) {
            this.jcbCerrar_mes.setSelectedItem(Mes[3]);
        }
        if (FechaMes.equalsIgnoreCase("05")) {
            this.jcbCerrar_mes.setSelectedItem(Mes[4]);
        }
        if (FechaMes.equalsIgnoreCase("06")) {
            this.jcbCerrar_mes.setSelectedItem(Mes[5]);
        }
        if (FechaMes.equalsIgnoreCase("07")) {
            this.jcbCerrar_mes.setSelectedItem(Mes[6]);
        }
        if (FechaMes.equalsIgnoreCase("08")) {
            this.jcbCerrar_mes.setSelectedItem(Mes[7]);
        }
        if (FechaMes.equalsIgnoreCase("09")) {
            this.jcbCerrar_mes.setSelectedItem(Mes[8]);
        }
        if (FechaMes.equalsIgnoreCase("10")) {
            this.jcbCerrar_mes.setSelectedItem(Mes[9]);
        }
        if (FechaMes.equalsIgnoreCase("11")) {
            this.jcbCerrar_mes.setSelectedItem(Mes[10]);
        }
        if (FechaMes.equalsIgnoreCase("12")) {
            this.jcbCerrar_mes.setSelectedItem(Mes[11]);
        }
        //////////////////////////////////////jComboBox6
        this.jComboBox7.removeAllItems();
        for (int a = 0; a <= 11; a++) {
            this.jComboBox7.addItem(Mes[a]);
        }
        if (FechaMes.equalsIgnoreCase("01")) {
            this.jComboBox7.setSelectedItem(Mes[0]);
        }
        if (FechaMes.equalsIgnoreCase("02")) {
            this.jComboBox7.setSelectedItem(Mes[1]);
        }
        if (FechaMes.equalsIgnoreCase("03")) {
            this.jComboBox7.setSelectedItem(Mes[2]);
        }
        if (FechaMes.equalsIgnoreCase("04")) {
            this.jComboBox7.setSelectedItem(Mes[3]);
        }
        if (FechaMes.equalsIgnoreCase("05")) {
            this.jComboBox7.setSelectedItem(Mes[4]);
        }
        if (FechaMes.equalsIgnoreCase("06")) {
            this.jComboBox7.setSelectedItem(Mes[5]);
        }
        if (FechaMes.equalsIgnoreCase("07")) {
            this.jComboBox7.setSelectedItem(Mes[6]);
        }
        if (FechaMes.equalsIgnoreCase("08")) {
            this.jComboBox7.setSelectedItem(Mes[7]);
        }
        if (FechaMes.equalsIgnoreCase("09")) {
            this.jComboBox7.setSelectedItem(Mes[8]);
        }
        if (FechaMes.equalsIgnoreCase("10")) {
            this.jComboBox7.setSelectedItem(Mes[9]);
        }
        if (FechaMes.equalsIgnoreCase("11")) {
            this.jComboBox7.setSelectedItem(Mes[10]);
        }
        if (FechaMes.equalsIgnoreCase("12")) {
            this.jComboBox7.setSelectedItem(Mes[11]);
        }
        //////////////////////////////////////jComboBox6
        this.jComboBox8.removeAllItems();
        for (int a = 0; a <= 11; a++) {
            this.jComboBox8.addItem(Mes[a]);
        }
        if (FechaMes.equalsIgnoreCase("01")) {
            this.jComboBox8.setSelectedItem(Mes[0]);
        }
        if (FechaMes.equalsIgnoreCase("02")) {
            this.jComboBox8.setSelectedItem(Mes[1]);
        }
        if (FechaMes.equalsIgnoreCase("03")) {
            this.jComboBox8.setSelectedItem(Mes[2]);
        }
        if (FechaMes.equalsIgnoreCase("04")) {
            this.jComboBox8.setSelectedItem(Mes[3]);
        }
        if (FechaMes.equalsIgnoreCase("05")) {
            this.jComboBox8.setSelectedItem(Mes[4]);
        }
        if (FechaMes.equalsIgnoreCase("06")) {
            this.jComboBox8.setSelectedItem(Mes[5]);
        }
        if (FechaMes.equalsIgnoreCase("07")) {
            this.jComboBox8.setSelectedItem(Mes[6]);
        }
        if (FechaMes.equalsIgnoreCase("08")) {
            this.jComboBox8.setSelectedItem(Mes[7]);
        }
        if (FechaMes.equalsIgnoreCase("09")) {
            this.jComboBox8.setSelectedItem(Mes[8]);
        }
        if (FechaMes.equalsIgnoreCase("10")) {
            this.jComboBox8.setSelectedItem(Mes[9]);
        }
        if (FechaMes.equalsIgnoreCase("11")) {
            this.jComboBox8.setSelectedItem(Mes[10]);
        }
        if (FechaMes.equalsIgnoreCase("12")) {
            this.jComboBox8.setSelectedItem(Mes[11]);
        }
        //////////////////////////////////////jComboBox6
        this.jComboBox9.removeAllItems();
        for (int a = 0; a <= 11; a++) {
            this.jComboBox9.addItem(Mes[a]);
        }
        if (FechaMes.equalsIgnoreCase("01")) {
            this.jComboBox9.setSelectedItem(Mes[0]);
        }
        if (FechaMes.equalsIgnoreCase("02")) {
            this.jComboBox9.setSelectedItem(Mes[1]);
        }
        if (FechaMes.equalsIgnoreCase("03")) {
            this.jComboBox9.setSelectedItem(Mes[2]);
        }
        if (FechaMes.equalsIgnoreCase("04")) {
            this.jComboBox9.setSelectedItem(Mes[3]);
        }
        if (FechaMes.equalsIgnoreCase("05")) {
            this.jComboBox9.setSelectedItem(Mes[4]);
        }
        if (FechaMes.equalsIgnoreCase("06")) {
            this.jComboBox9.setSelectedItem(Mes[5]);
        }
        if (FechaMes.equalsIgnoreCase("07")) {
            this.jComboBox9.setSelectedItem(Mes[6]);
        }
        if (FechaMes.equalsIgnoreCase("08")) {
            this.jComboBox9.setSelectedItem(Mes[7]);
        }
        if (FechaMes.equalsIgnoreCase("09")) {
            this.jComboBox9.setSelectedItem(Mes[8]);
        }
        if (FechaMes.equalsIgnoreCase("10")) {
            this.jComboBox9.setSelectedItem(Mes[9]);
        }
        if (FechaMes.equalsIgnoreCase("11")) {
            this.jComboBox9.setSelectedItem(Mes[10]);
        }
        if (FechaMes.equalsIgnoreCase("12")) {
            this.jComboBox9.setSelectedItem(Mes[11]);
        }
    }

    private void llenarDoctorPaciente() {

        jcboDoctor.removeAllItems();
        jcboDoctorBuscar.removeAllItems();

        //el DR. puede cambiar segun la prestacion
        jcboDoctor.addItem("Selecione Odontologo");
        jcboDoctorBuscar.addItem("Selecione Odontologo");
        jComboBox5.addItem("Selecione Odontologo");
        jComboBox2.addItem("Selecione Odontologo");
        jcbInfo_Odon1.addItem("Selecione Odontologo");
        jcbInfo_Odon2.addItem("Selecione Odontologo");


        Iterator it = neg.getListarOdontologo().iterator();
        while (it.hasNext()) {
            GEN_PROFESIONAL doc = (GEN_PROFESIONAL) it.next();
            try {
                if (doc.getNombre2_prof().equalsIgnoreCase(null)) {
                } else {
                    doc.setNombre2_prof(" " + doc.getNombre2_prof());
                }
            } catch (Exception ex) {
                doc.setNombre2_prof(" ");
            }

            jcboDoctor.addItem(doc.getApepat_prof().replace('Ñ', 'N') + " " + doc.getApemat_prof().replace('Ñ', 'N') + " "
                    + doc.getNombre1_prof().replace('Ñ', 'N') + doc.getNombre2_prof().replace('Ñ', 'N') + "(" + doc.getRut_prof() + "-" + doc.getDv_prof() + ")");
            jcboDoctorBuscar.addItem(doc.getApepat_prof().replace('Ñ', 'N') + " " + doc.getApemat_prof().replace('Ñ', 'N') + " "
                    + doc.getNombre1_prof().replace('Ñ', 'N') + doc.getNombre2_prof().replace('Ñ', 'N') + "(" + doc.getRut_prof() + "-" + doc.getDv_prof() + ")");
            jComboBox5.addItem(doc.getApepat_prof().replace('Ñ', 'N') + " " + doc.getApemat_prof().replace('Ñ', 'N') + " "
                    + doc.getNombre1_prof().replace('Ñ', 'N') + doc.getNombre2_prof().replace('Ñ', 'N') + "(" + doc.getRut_prof() + "-" + doc.getDv_prof() + ")");
            jComboBox2.addItem(doc.getApepat_prof().replace('Ñ', 'N') + " " + doc.getApemat_prof().replace('Ñ', 'N') + " "
                    + doc.getNombre1_prof().replace('Ñ', 'N') + doc.getNombre2_prof().replace('Ñ', 'N') + "(" + doc.getRut_prof() + "-" + doc.getDv_prof() + ")");
            jcbInfo_Odon1.addItem(doc.getApepat_prof().replace('Ñ', 'N') + " " + doc.getApemat_prof().replace('Ñ', 'N') + " "
                    + doc.getNombre1_prof().replace('Ñ', 'N') + doc.getNombre2_prof().replace('Ñ', 'N') + "(" + doc.getRut_prof() + "-" + doc.getDv_prof() + ")");
            jcbInfo_Odon2.addItem(doc.getApepat_prof().replace('Ñ', 'N') + " " + doc.getApemat_prof().replace('Ñ', 'N') + " "
                    + doc.getNombre1_prof().replace('Ñ', 'N') + doc.getNombre2_prof().replace('Ñ', 'N') + "(" + doc.getRut_prof() + "-" + doc.getDv_prof() + ")");
        }

        this.jcDetalle.addItem("Detalle del Pago");
        this.jcboDoctor.setSelectedIndex(0);
        this.jcboDoctorBuscar.setSelectedIndex(0);

    }

    private void salir() {
        int opcion = 0;
        opcion = JOptionPane.showConfirmDialog(this,
                "¿Desea Salir de la Aplicación?",
                "Salir de Aplicación",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE);
        if (opcion == JOptionPane.YES_OPTION) {
            File fichero = new File("C:\\WINDOWS\\Temp\\*.xls");
            //eliminar.....
            fichero.delete();
            System.exit(0);
        }
    }

    private void CalculosDr(double totalmes) {
        ValidaSucursal();
        if (totalmes >= 0) {
            try {
                Sucursal su = new Sucursal();
                config cf = new config();

                double a5 = 0;
                double s6 = 0;

                if (!neg.Cerrado(this.jcboFecha.getSelectedItem().toString(), Integer.parseInt(faño.format(jtxtAño.getValue())), su.getSucursal())) {

                    Iterator itsu = neg.ListarSucursales().iterator();
                    while (itsu.hasNext()) {
                        Sucursales suc = (Sucursales) itsu.next();

                        if (suc.getSucursales().equalsIgnoreCase("San Antonio") && su.getSucursal().equalsIgnoreCase("1")) {
                            a5 = Double.parseDouble("0." + suc.getParticipacion());
                            s6 = Double.parseDouble("0." + suc.getRetencion());
                        }
                        if (suc.getSucursales().equalsIgnoreCase("Bandera") && su.getSucursal().equalsIgnoreCase("2")) {
                            a5 = Double.parseDouble("0." + suc.getParticipacion());
                            s6 = Double.parseDouble("0." + suc.getRetencion());
                        }
                        if (suc.getSucursales().equalsIgnoreCase("Manuel Montt") && su.getSucursal().equalsIgnoreCase("3")) {
                            a5 = Double.parseDouble("0." + suc.getParticipacion());
                            s6 = Double.parseDouble("0." + suc.getRetencion());
                        }
                        if (suc.getSucursales().equalsIgnoreCase("La Florida") && su.getSucursal().equalsIgnoreCase("5")) {
                            a5 = Double.parseDouble("0." + suc.getParticipacion());
                            s6 = Double.parseDouble("0." + suc.getRetencion());
                        }
                    }

                } else {
                    Iterator it = neg.MesCerrado(this.jcboFecha.getSelectedItem().toString(), Integer.parseInt(faño.format(jtxtAño.getValue())), Integer.parseInt(su.getSucursal())).iterator();
                    while (it.hasNext()) {
                        CerrarMes cm = (CerrarMes) it.next();
                        a5 = Double.parseDouble("0." + cm.getPorsentaje());
                        s6 = Double.parseDouble("0." + cm.getRetencion());

                    }
                }


                double a1 = totalmes * a5;
                double b1 = (a1 + Bono) * s6;
                double validar = (a1 + Bono) - b1;
                jTextField5.setText("" + df.format(totalmes));
                jTextField2.setText("" + df.format(a1));
                jTextField16.setText("" + df.format(Bono));
                jTextField23.setText("" + df.format(TotalLab));
                jTextField24.setText("" + df.format(TotalRayo));
                //NETO TRABAJOS TERMINADOS

                if (this.jcboDoctorBuscar.getSelectedItem().toString().equalsIgnoreCase("AYARZA GOENAGA JULIAN (6888148-K)") && cf.getActivaRetencion().equalsIgnoreCase("true")) {
                    this.jTextField3.setText("No retención");
                    this.jTextField4.setText("" + df.format(a1 + Bono));
                } else {
                    this.jTextField3.setText("" + df.format(b1));
                    this.jTextField4.setText("" + df.format(validar));
                }
            } catch (IOException ex) {
                Logger.getLogger(GUI1.class.getName()).log(Level.SEVERE, null, ex);
                JOptionPane.showMessageDialog(this,
                        "Archivo mal Configurado",
                        "Error",
                        JOptionPane.WARNING_MESSAGE);

            }
        } else {
            jTextField16.setText("" + df.format(Bono));
            this.jTextField5.setText("" + df.format(totalmes));
            this.jTextField2.setText("" + df.format(0));
            this.jTextField3.setText("" + df.format(0));
            this.jTextField4.setText("" + df.format(totalmes + Bono));

        }
    }

    private void seguridad() {
        Usuarios us = new Usuarios();
        ValidaSucursal();
        try {
            Sucursal su = new Sucursal();
            boolean valida;
            if (su.getFuncionar().trim().equalsIgnoreCase("Wizard")) {
                valida = true;
            } else {
                valida = false;
            }
            if (valida) {
                //validar si es nesesario mostrar el cambio de sucursal
                if (us.isCambioSucursal()) {
                    this.jbtSanAntonio.setEnabled(true);
                    this.jbtBandera.setEnabled(true);
                    this.jbtMontt.setEnabled(true);
                    this.jbtLaFlorida.setEnabled(true);
                }
            } else {
                // System.exit(0);
                Activar.setVisible(true);
                Activar.pack();
                Activar.setLocation(150, 70);
                this.desactiva();
                //cerrar el programa...
            }
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this,
                    "Error en la configuracion del Programa",
                    "Error",
                    JOptionPane.WARNING_MESSAGE);
            System.exit(0);
        }
    }

    public void Guardar(String rut_doc) throws IOException {

        if (validaAño(faño.format(jTextField14.getValue()))) {
            NegocioInsert ni = new NegocioInsert();
            Sucursal su = new Sucursal();
            //validar que la liquidacion no sea mayor a la diferencia entre valor.pres y total pagado
            long valor_pres_total_pagado = ValorPrestacion - (TotalPagado + TotalLab + TotalRayo);
            int liquidacion = 0;
            int laboratorio = 0;
            int rayos = 0;
            try {
                liquidacion = Integer.parseInt(this.jtxtPago.getText().trim());
                laboratorio = Integer.parseInt(this.jcbLaboratorio.getText().trim());
                rayos = Integer.parseInt(this.jtxtRayos.getText().trim());
            } catch (Exception Ex) {
            }

            if (valor_pres_total_pagado >= liquidacion && valor_pres_total_pagado >= laboratorio && valor_pres_total_pagado >= rayos && valor_pres_total_pagado >= (laboratorio + liquidacion + rayos)) {// && liquidacion > 0) {

                if (!this.jtxtPago.getText().equalsIgnoreCase("0") || !this.jcbLaboratorio.getText().equalsIgnoreCase("0") || !this.jtxtRayos.getText().equalsIgnoreCase("0")) {
                    int opcion = 0;
                    opcion = JOptionPane.showConfirmDialog(this,
                            "¿Desea Guardar esta Liquidacion?"
                            + "\n Liquidacion=" + df.format(Integer.parseInt(this.jtxtPago.getText()))
                            + "\n Laboratorio=" + df.format(Integer.parseInt(this.jcbLaboratorio.getText()))
                            + "\n Radiografia=" + df.format(Integer.parseInt(this.jtxtRayos.getText()))
                            + "\n Fecha=" + this.jcboFechaIngreso.getSelectedItem().toString()
                            + "\n"
                            + "\n" + this.jcboDoctor.getSelectedItem().toString(),
                            "Confirmacion",
                            JOptionPane.YES_NO_OPTION,
                            JOptionPane.INFORMATION_MESSAGE);

                    if (opcion == JOptionPane.YES_OPTION) {
                        //seteo la capa Pago

                        if (neg.Cerrado(this.jcboFechaIngreso.getSelectedItem().toString(), Integer.parseInt(faño.format(jTextField14.getValue())), su.getSucursal())) {
                            JOptionPane.showMessageDialog(this,
                                    "Este Mes ya se encuentra Cerrado",
                                    "Error",
                                    JOptionPane.WARNING_MESSAGE);
                        } else {
                            Pago pag = new Pago();

                            pag.setNumero_presupuesto(Integer.parseInt(this.jtxtPresupuesto.getText()));
                            pag.setDoc_rut(this.jcboDoctor.getSelectedItem().toString());

                            //validar que el rut del paciente..
                            pag.setPaciente_rut(this.jtxtPaciente.getText());

                            pag.setPag_num_boleta(Integer.parseInt(this.jtxtBoleta.getText()));
                            pag.setLiquidacion(Integer.parseInt(this.jtxtPago.getText()));
                            pag.setLaboratorio(Integer.parseInt(this.jcbLaboratorio.getText()));
                            pag.setBono(0);
                            pag.setRayosDarsalud(Integer.parseInt(this.jtxtRayos.getText()));
                            //seteo fecha desde el equipo. .dia / mes / año

                            pag.setGuardadoEl(FechaDia + "/" + FechaMesActual + "/" + FechaAño);

                            int mm = this.jcboFechaIngreso.getSelectedIndex() + 1;
                            String FechaMes = "" + mm;
                            for (int num = 1; num <= 9; num++) {
                                if (mm == num) { //agrego un 0 si es mes es menor a 9
                                    FechaMes = "0" + mm;
                                }
                            }

                            pag.setFecha(FechaDia + "/" + FechaMes + "/" + faño.format(jTextField14.getValue()));

                            pag.setDetalle(this.jcDetalle.getSelectedItem().toString());

                            pag.setCOD_SUCURSAL(su.getSucursal());
                            pag.setIngresoPor(this.jtxtUser.getText());
                            pag.setValorPrestacion(ValorPrestacion);

                            ni.agregarPago(pag);

                            this.jtxtPresupuesto.requestFocus();
                            buscaPresu();
                            this.jtxtPago.setText("0");
                            this.jcbLaboratorio.setText("0");
                            this.jtxtRayos.setText("0");
                            this.jtxtPresupuesto.setText("");
                            this.jbtGuardar.setEnabled(false);
                            this.jtxtPago.setEnabled(false);

                        }
                    }
                } else {
                    JOptionPane.showMessageDialog(this,
                            "Se debe liquidar algo (Odontologo, Laboratorio o Rayo)",
                            "Error",
                            JOptionPane.WARNING_MESSAGE);
                }

            } else {
                JOptionPane.showMessageDialog(this,
                        "El Valor Maximo para Liquidar es \n" + df.format(valor_pres_total_pagado),
                        "Error",
                        JOptionPane.WARNING_MESSAGE);

                jtxtPago.setText("0");
                jcbLaboratorio.setText("0");
                jtxtRayos.setText("0");
            }
        } else {
            JOptionPane.showMessageDialog(this,
                    "Fecha no Corresponde",
                    "Error",
                    JOptionPane.WARNING_MESSAGE);
        }

    }

    public void buscaPresu() {
        int Numpres = 0;
        try {
            Numpres = Integer.parseInt(jtxtPresupuesto.getText());
        } catch (NumberFormatException ex) {
        }
        try {
            this.jcDetalle.removeAllItems();
            TotalPagado = 0;
            TotalLab = 0;
            TotalRayo = 0;
            ValorPrestacion = 0;

            Iterator it_pres_ora = neg.getBuscarPresuTablaOracle(Numpres).iterator();
            String[] campos = {"Prestacion", "Nombre Prestacion", "Cara", "Pieza", "Valor", "Abono", "Saldo", "Efectuada", "Pagada"};
            DefaultTableModel model = new DefaultTableModel();
            int filas = neg.getBuscarPresuTablaOracle(Numpres).size();
            Object[][] datos = new Object[filas][9];
            String validar = "0";

            if (validar.equalsIgnoreCase("" + filas)) {
                jtOracle.setVisible(false);
                jbtGuardar.setEnabled(false);
                jtxtPago.setEnabled(false);
                jcbLaboratorio.setEditable(false);
                jtxtRayos.setEditable(false);
                jcboDoctor.setSelectedIndex(0);
                jtxtPaciente.setText("");

                JOptionPane.showMessageDialog(this,
                        "No hay Datos.",
                        "No Dato",
                        JOptionPane.INFORMATION_MESSAGE);

            } else {
                jtOracle.setVisible(true);
                jbtGuardar.setEnabled(true);
                jtxtPago.setEnabled(true);
                jcbLaboratorio.setEditable(true);
                jtxtRayos.setEditable(true);
            }
            for (int i = 0; i < filas; i++) {
                TablaOracle ta = (TablaOracle) it_pres_ora.next();
                ValorPrestacion += ta.getValor();

                if (ta.getNombrePrestacion().equalsIgnoreCase("SESIONES")) {
                } else {
                    jcDetalle.addItem(ta.getNombrePrestacion() + ", " + ta.getPieza());

                    nomproce.add(ta.getNombrePrestacion() + ", " + ta.getPieza());

                    canti.add(ta.getValor());

                }
                datos[i][0] = ta.getCODADD_PRES();
                datos[i][1] = ta.getNombrePrestacion();
                datos[i][2] = ta.getCara();
                datos[i][3] = ta.getPieza();
                datos[i][4] = df.format(ta.getValor());
                datos[i][5] = df.format(ta.getAbono());
                datos[i][6] = df.format(ta.getSaldo());
                try {
                    if (ta.getEfectuada().equalsIgnoreCase("e")) {
                        datos[i][7] = "EFECTUADA";
                    } else {
                        datos[i][7] = "No";
                    }
                } catch (Exception ex) {
                    datos[i][7] = "No";
                }
                try {
                    if (ta.getPagada().equalsIgnoreCase("A")) {
                        datos[i][8] = "Abono";
                    } else {
                        if (ta.getPagada().equalsIgnoreCase("S")) {
                            datos[i][8] = "Si";
                        } else {
                            datos[i][8] = "No";
                        }
                    }

                } catch (Exception Ez) {
                    datos[i][8] = "No";
                }
                model.setDataVector(datos, campos);
                //seteo la jtable con el table model
                jtOracle.setModel(model);
                jtOracle.setEnabled(false);
                //cambiamos el ancho de las columnas
                TableColumn column = null;
                column = this.jtOracle.getColumnModel().getColumn(0);
                column.setPreferredWidth(200);
                column = this.jtOracle.getColumnModel().getColumn(1);
                column.setPreferredWidth(700);
                column = this.jtOracle.getColumnModel().getColumn(2);
                column.setPreferredWidth(100);
                column = this.jtOracle.getColumnModel().getColumn(3);
                column.setPreferredWidth(100);
                column = this.jtOracle.getColumnModel().getColumn(4);
                column.setPreferredWidth(150);
                column = this.jtOracle.getColumnModel().getColumn(5);
                column.setPreferredWidth(150);
                column = this.jtOracle.getColumnModel().getColumn(6);
                column.setPreferredWidth(150);
                column = this.jtOracle.getColumnModel().getColumn(7);
                column.setPreferredWidth(100);
                column = this.jtOracle.getColumnModel().getColumn(8);
                column.setPreferredWidth(100);
                // }
            }
            jtxtValorPresupuesto.setText("" + df.format(ValorPrestacion));
            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
            //BUSCAR EL PRESU EN ACCESS
            Iterator it = neg.getBuscarPago(Numpres).iterator();
            String[] camposa = {"Fecha", "Liquidado", "Laboratorio", "Rayos", "Descripcion", "Doctores", "Boleta", "Reg", "Eliminar"};
            DefaultTableModel modela = new DefaultTableModel();
            int filasa = neg.getBuscarPago(Numpres).size();
            //creo una matriz
            Object[][] datosa = new Object[filasa][9];

            if (0 == filasa) {
                this.jtAccess.setModel(modela);
                //  this.jtAccess.setVisible(false);
            }

            for (int i = 0; i < filasa; i++) {
                Pago pag = (Pago) it.next();
                jScrollPane1.setVisible(true);
                jtAccess.setVisible(true);
                TotalLab += pag.getLaboratorio();
                TotalRayo += pag.getRayosDarsalud();
                TotalPagado += pag.getLiquidacion();

                datosa[i][0] = pag.getFecha().substring(8, 10) + "-" + pag.getFecha().substring(5, 7) + "-" + pag.getFecha().substring(0, 4);
                //busco los Rut de los DR asociados a la BD Access
                datosa[i][1] = df.format(pag.getLiquidacion());
                datosa[i][2] = df.format(pag.getLaboratorio());
                datosa[i][3] = df.format(pag.getRayosDarsalud());
                datosa[i][4] = pag.getDetalle();
                datosa[i][5] = pag.getDoc_rut();
                datosa[i][6] = pag.getPag_num_boleta();
                datosa[i][7] = pag.getPd_id();// + " (" + pag.getNumero_presupuesto() + ")";
                datosa[i][8] = new Button("Eliminar");

                //cargar datos en la tabla
                modela.setDataVector(datosa, camposa);
                //seteo la jtable con el table model
                this.jtAccess.setModel(modela);
                //cambiamos el ancho de las columnas
                TableColumn column = null;
                this.jtAccess.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
                column = this.jtAccess.getColumnModel().getColumn(0);
                column.setPreferredWidth(70);
                column = this.jtAccess.getColumnModel().getColumn(1);
                column.setPreferredWidth(70);
                column = this.jtAccess.getColumnModel().getColumn(2);
                column.setPreferredWidth(70);
                column = this.jtAccess.getColumnModel().getColumn(3);
                column.setPreferredWidth(60);
                column = this.jtAccess.getColumnModel().getColumn(4);
                column.setPreferredWidth(250);
                column = this.jtAccess.getColumnModel().getColumn(5);
                column.setPreferredWidth(350);
                column = this.jtAccess.getColumnModel().getColumn(6);
                column.setPreferredWidth(50);
                column = this.jtAccess.getColumnModel().getColumn(7);
                column.setPreferredWidth(50);
                column = this.jtAccess.getColumnModel().getColumn(8);
                column.setPreferredWidth(150);
            }
            try {
                TableColumn agregarColumn;
                agregarColumn = jtAccess.getColumnModel().getColumn(8);
                agregarColumn.setCellEditor(new myeditor(jtAccess, this.jtxtUser.getText().toUpperCase()));
                agregarColumn.setCellRenderer(new myrenderer(true));
                jtAccess.setEditingColumn(1);

            } catch (ArrayIndexOutOfBoundsException ex) {
            }
            //auto seleccionar 1 DR.
            Iterator it_doc = neg.getBuscarOdontologo(Numpres).iterator();
            while (it_doc.hasNext()) {
                GEN_PROFESIONAL doc = (GEN_PROFESIONAL) it_doc.next();
                try {
                    if (doc.getNombre2_prof().equalsIgnoreCase(null)) {
                    } else {
                        doc.setNombre2_prof(" " + doc.getNombre2_prof());
                    }
                } catch (Exception ex) {
                    doc.setNombre2_prof(" ");
                }
                this.jcboDoctor.setSelectedItem(doc.getApepat_prof().replace('Ñ', 'N') + " " + doc.getApemat_prof().replace('Ñ', 'N') + " " + doc.getNombre1_prof().replace('Ñ', 'N') + doc.getNombre2_prof().replace('Ñ', 'N') + "(" + doc.getRut_prof() + "-" + doc.getDv_prof() + ")");
            }
            //RESCATO EL NOMBRE DEL PACIENTE...
            Iterator it_pac = neg.getBuscarPaciente(Numpres).iterator();
            while (it_pac.hasNext()) {
                Tab_Paciente pac = (Tab_Paciente) it_pac.next();
                this.jtxtPaciente.setText(pac.getNOMBRE_PACIENTE() + " " + pac.getAPEPAT_PACIENTE() + " " + pac.getAPEMAT_PACIENTE() + "(" + pac.getRUT_PACIENTE() + "-" + pac.getDV_PACIENTE() + ")");
            }
            //sumas de los pagos en Access
            this.jtxtTotalPagado.setText("" + df.format(TotalPagado));
            this.jtxtTotalLab.setText("" + df.format(TotalLab));
            this.jTextField15.setText("" + df.format(TotalRayo));
            this.jcDetalle.addItem("Por el Total del Presupuesto.");
            this.jcDetalle.addItem("Sin Descripción…");
        } catch (IOException ex) {
            Logger.getLogger(GUI1.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public String ValidaFecha(int mm, String año) {
        String fecha = "1999/01/31";//formato
        int aa = Integer.parseInt(año.trim().substring((año.length() - 4), año.length()));
        int dm = 31; //asumo que todos los meses del año tienen 31 dias!!!
        if (mm == 4 || mm == 6 || mm == 9 || mm == 11) { //estos meses tienen 30 dias
            dm = 30;
        } else {// febrero es de problema se trata de una manera diferente
            if (mm == 2) {
                dm = 28;// asumo que todos los años febrero tiene 28 dia
                if (aa % 4 == 0) {// si es un año bisiesto febrero tiene 29 dias!!!(esta es la forma de ver si un año es bisiesto o no!)
                    dm = 29;
                }
            }
        }
        String mes = "" + mm;
        for (int num = 1; num <= 9; num++) {
            if (mm == num) { //agrego un 0 si es mes es menor a 9
                mes = "0" + mm;
            }
        }
        fecha = aa + "/" + mes + "/" + dm;
        return fecha;
    }

    private void ValidaSucursal() {
        try {
            Sucursal su = new Sucursal();

            if (!neg.Cerrado(this.jcboFecha.getSelectedItem().toString(), Integer.parseInt(faño.format(jtxtAño.getValue())), su.getSucursal())) {
                Iterator itsu = neg.ListarSucursales().iterator();
                while (itsu.hasNext()) {
                    Sucursales suc = (Sucursales) itsu.next();

                    if (suc.getSucursales().equalsIgnoreCase("San Antonio") && su.getSucursal().equalsIgnoreCase("1")) {
                        this.jLabel3.setText("HONORARIOS " + suc.getParticipacion() + " %");
                        this.jLabel4.setText("RETENCION " + suc.getRetencion() + " %");

                    }
                    if (suc.getSucursales().equalsIgnoreCase("Bandera") && su.getSucursal().equalsIgnoreCase("2")) {
                        this.jLabel3.setText("HONORARIOS " + suc.getParticipacion() + " %");
                        this.jLabel4.setText("RETENCION " + suc.getRetencion() + " %");

                    }
                    if (suc.getSucursales().equalsIgnoreCase("Manuel Montt") && su.getSucursal().equalsIgnoreCase("3")) {
                        this.jLabel3.setText("HONORARIOS " + suc.getParticipacion() + " %");
                        this.jLabel4.setText("RETENCION " + suc.getRetencion() + " %");

                    }
                    if (suc.getSucursales().equalsIgnoreCase("La Florida") && su.getSucursal().equalsIgnoreCase("5")) {
                        this.jLabel3.setText("HONORARIOS " + suc.getParticipacion() + " %");
                        this.jLabel4.setText("RETENCION " + suc.getRetencion() + " %");

                    }
                }
            } else {
                Iterator it = neg.MesCerrado(this.jcboFecha.getSelectedItem().toString(), Integer.parseInt(faño.format(jtxtAño.getValue())), Integer.parseInt(su.getSucursal())).iterator();
                while (it.hasNext()) {
                    CerrarMes cm = (CerrarMes) it.next();
                    this.jLabel3.setText("HONORARIOS " + cm.getPorsentaje() + " %");
                    this.jLabel4.setText("RETENCION " + cm.getRetencion() + " %");
                }
            }
            if (su.getSucursal().equalsIgnoreCase("1")) {
                jLabel2.setText("San Antonio");
                jTextField1.setText("San Antonio");
                jLabel16.setText("Access San Antonio");
                jlbCerrar_sucursal.setText("San Antonio");
                jLabelSucursalInformes.setText("San Antonio");
            }
            if (su.getSucursal().equalsIgnoreCase("2")) {
                jLabel2.setText("Bandera");
                jTextField1.setText("Bandera");
                jLabel16.setText("Access Bandera");
                jlbCerrar_sucursal.setText("Bandera");
                jLabelSucursalInformes.setText("Bandera");
            }
            if (su.getSucursal().equalsIgnoreCase("3")) {
                jLabel2.setText("Manuel Montt");
                jTextField1.setText("Manuel Montt");
                jLabel16.setText("Access Manuel Montt");
                jlbCerrar_sucursal.setText("Manuel Montt");
                jLabelSucursalInformes.setText("Manuel Montt");
            }
            if (su.getSucursal().equalsIgnoreCase("5")) {
                jLabel2.setText("La Florida");
                jTextField1.setText("La Florida");
                jLabel16.setText("Access La Florida");
                jlbCerrar_sucursal.setText("La Florida");
                jLabelSucursalInformes.setText("La Florida");
            }
        } catch (IOException ex) {
            System.out.println("EROOR!!!!!" + ex);

        }

    }

    private int CalcularPresu(int numero_presupuesto) {
        int suma = 0;
        Iterator it = neg.getBuscarPresupuesto(numero_presupuesto).iterator();
        while (it.hasNext()) {
            AM_PRESUDET avd = (AM_PRESUDET) it.next();
            suma = +avd.getVALOR_PRESUDET();
        }
        return suma;
    }

    private void cargaFondo() {
        try {

//            jLabel37.setIcon(new javax.swing.ImageIcon(getClass().getResource("/CapaGUI/dental.png")));
//            jLabel38.setIcon(new javax.swing.ImageIcon(getClass().getResource("/CapaGUI/dental.png")));
            //     jLabel26.setIcon(new javax.swing.ImageIcon(getClass().getResource("/CapaGUI/dental.png")));
            jLabel25.setIcon(new javax.swing.ImageIcon(getClass().getResource("/CapaGUI/dental.png")));
            jlOcultarIngreso.setIcon(new javax.swing.ImageIcon(getClass().getResource("/CapaGUI/dental.png")));

            //     jLabel26.setIcon(new javax.swing.ImageIcon(getClass().getResource("/CapaGUI/logoDarSalud.png")));
//            jLabel23.setIcon(new javax.swing.ImageIcon(getClass().getResource("/CapaGUI/dental.png")));
//            jLabel31.setIcon(new javax.swing.ImageIcon(getClass().getResource("/CapaGUI/dental.png")));
        } catch (NullPointerException ex) {
            System.out.println(ex);
        }
    }

    private void desactiva() {

        jTextField14.setVisible(false);
        this.jtverBonos.setEnabled(false);
        //.setVisible(false);
        //   this.jLabel26.setVisible(true);

        //ingresa
        jtxtPresupuesto.setVisible(false);
        jcDetalle.setVisible(false);
        jcboDoctor.setVisible(false);
        jtxtPaciente.setVisible(false);
        jbtGuardar.setVisible(false);
        jtxtBoleta.setVisible(false);
        jtxtPago.setVisible(false);
        jcbLaboratorio.setVisible(false);
        jtxtRayos.setVisible(false);
        jcboFechaIngreso.setVisible(false);
        jtxtTotalPagado.setVisible(false);
        jtxtTotalLab.setVisible(false);
        jtxtValorPresupuesto.setVisible(false);

        //informe 
        jcboDoctorBuscar.setVisible(false);
        jcboFecha.setVisible(false);
        jtxtAño.setVisible(false);
        jbtBuscarDoctor.setVisible(false);
        jTextField1.setVisible(false);
        jbtExExcelDr.setVisible(false);
        jbtExExcelDr1.setVisible(false);
        jbtExExcelDr2.setVisible(false);
        jTextField5.setVisible(false);
        jTextField2.setVisible(false);
        jTextField3.setVisible(false);
        jTextField4.setVisible(false);
        jTextField15.setVisible(false);

        jcbInfo_Odon1.setVisible(false);
        jcbInfo_Odon2.setVisible(false);
        jComboBox7.setVisible(false);
        jTextField9.setVisible(false);
        jTextField10.setVisible(false);
        jTextField11.setVisible(false);
        jComboBox8.setVisible(false);
        jbtExExcelDr3.setVisible(false);
        jComboBox9.setVisible(false);
        jTextField12.setVisible(false);

        //bonos
        jComboBox1.setVisible(false);
        jComboBox2.setVisible(false);
        jTextField6.setVisible(false);
        jComboBox3.setVisible(false);
        jbtGuardarBono.setVisible(false);
        jComboBox4.setVisible(false);
        jbtVerBono.setVisible(false);
        jComboBox5.setVisible(false);
        jtxtAñoBono.setVisible(false);

        //Cerrar mes
        jcbCerrar_mes.setVisible(false);
        jtxtCerrar_Año.setVisible(false);

    }

    private void Activa() {
        //esconde el login
        jlbBackgroundLogin.setVisible(false);
        jTextField14.setVisible(true);
        jBtLogin.setVisible(false);
        jtxtPass.setVisible(false);
        jtxtUser.setVisible(false);
        jlbPass.setVisible(false);
        jLbUser.setVisible(false);
        // jLabel26.setVisible(false);

        //ingresa
        jtxtPresupuesto.setVisible(true);
        jcDetalle.setVisible(true);
        jcboDoctor.setVisible(true);
        jtxtPaciente.setVisible(true);

        jtxtBoleta.setVisible(true);

        jcbLaboratorio.setVisible(true);
        jtxtRayos.setVisible(true);
        jcboFechaIngreso.setVisible(true);
        jtxtTotalPagado.setVisible(true);
        jtxtTotalLab.setVisible(true);
        jtxtValorPresupuesto.setVisible(true);
        jTextField15.setVisible(true);

        jcbInfo_Odon1.setVisible(true);
        jcbInfo_Odon2.setVisible(true);
        jComboBox7.setVisible(true);
        jTextField9.setVisible(true);
        jTextField10.setVisible(true);
        jTextField11.setVisible(true);
        jComboBox8.setVisible(true);

        jComboBox9.setVisible(true);
        jTextField12.setVisible(true);


        //informe
        jcboDoctorBuscar.setVisible(true);
        jcboFecha.setVisible(true);
        jtxtAño.setVisible(true);

        jTextField1.setVisible(true);

        jTextField5.setVisible(true);
        jTextField2.setVisible(true);
        jTextField3.setVisible(true);
        jTextField4.setVisible(true);

        //Cerrar mes
        jcbCerrar_mes.setVisible(true);
        jtxtCerrar_Año.setVisible(true);

    }

//    private void actualizaContraseñas() {
//
//        NegocioInsert ni = new NegocioInsert();
//        Iterator it = neg.ListarUser().iterator();
//        while (it.hasNext()) {
//            Usuarios us = (Usuarios) it.next();
//            us.setPass(neg.getBuscarUser(us.getUsuario()));
//            ni.ModificarPassUser(us);
//        }
//    }
    private void VerBono() {
        if (validaAño(faño.format(jtxtAñoBono.getValue()))) {
            try {
                // TODO add your handling code here:
                ArrayList listaBono = neg.getListarAbonos(this.jComboBox2.getSelectedItem().toString(), ValidaFecha(this.jComboBox3.getSelectedIndex() + 1, this.jTextField7.getValue().toString()));
                Iterator it = listaBono.iterator();
                String[] camposa = {"Fecha", "Descripcion", "Cantidad", "Reg"};
                DefaultTableModel modela = new DefaultTableModel();
                int filasa = listaBono.size();
                //creo una matriz
                Object[][] datosa = new Object[filasa][4];

                if (0 == filasa) {

                    jtverBonos.setModel(new DefaultTableModel());
                    JOptionPane.showMessageDialog(this,
                            "No hay Datos.",
                            "No Dato",
                            JOptionPane.INFORMATION_MESSAGE);
                }

                for (int i = 0; i < filasa; i++) {
                    jtverBonos.setVisible(true);
                    Pago pag = (Pago) it.next();

                    datosa[i][0] = pag.getFecha().substring(8, 10) + "-" + pag.getFecha().substring(5, 7) + "-" + pag.getFecha().substring(0, 4);
                    datosa[i][1] = pag.getDetalle();
                    datosa[i][2] = df.format(pag.getBono());
                    datosa[i][3] = pag.getPd_id();
                    //cargar datos en la tabla
                    modela.setDataVector(datosa, camposa);
                    //seteo la jtable con el table model
                    this.jtverBonos.setModel(modela);
                    this.jtverBonos.setEnabled(false);
                    //cambiamos el ancho de las columnas
                    TableColumn column = null;
                    column = this.jtverBonos.getColumnModel().getColumn(0);
                    column.setPreferredWidth(120);
                    column = this.jtverBonos.getColumnModel().getColumn(1);
                    column.setPreferredWidth(250);
                    column = this.jtverBonos.getColumnModel().getColumn(2);
                    column.setPreferredWidth(400);
                    column = this.jtverBonos.getColumnModel().getColumn(3);
                    column.setPreferredWidth(100);
                }
            } catch (IOException ex) {
                Logger.getLogger(GUI1.class.getName()).log(Level.SEVERE, null, ex);
            }
        } else {
            JOptionPane.showMessageDialog(this,
                    "No hay Datos.",
                    "No Dato",
                    JOptionPane.INFORMATION_MESSAGE);
        }
    }

    private void privilegios() {
//      NegocioInsert ni = new NegocioInsert();
//      ni.AgregarLaFlorida();
       Iterator it = neg.Seguridad(this.jtxtUser.getText(), this.jtxtPass.getText()).iterator();
        boolean entra = true;
        while (it.hasNext()) {
            Usuarios us = (Usuarios) it.next();
            //activacion de uso basico
            jTextField27.setText(us.getApePat() + " " + us.getApeMat() + " " + us.getNombre());
            entra = false;
            if (us.isEntra()) {
                this.Activa();

                //cambio de sucursal
                if (us.isCambioSucursal()) {
                    jLabel2.setVisible(true);
                    jbtBandera.setVisible(true);
                    jbtMontt.setVisible(true);
                    jbtSanAntonio.setVisible(true);
                    jbtBandera.setEnabled(true);
                    jbtMontt.setEnabled(true);
                    jbtLaFlorida.setEnabled(true);
                    jbtSanAntonio.setEnabled(true);
                } else {
                    jLabel2.setVisible(false);
                    jbtBandera.setVisible(false);
                    jbtMontt.setVisible(false);
                    jbtSanAntonio.setVisible(false);
                }
                //activacion para bono
                if (us.isBonosViaje()) {
                    //bonos
                    jLabel27.setVisible(true);
                    jComboBox5.setVisible(true);
                    jLabel28.setVisible(true);
                    jComboBox1.setVisible(true);
                    jLabel29.setVisible(true);
                    jLabel30.setVisible(true);
                    jTextField6.setVisible(true);
                    jComboBox4.setVisible(true);
                    jbtGuardarBono.setVisible(true);
                    jLabel31.setVisible(false);
                    this.jtxtAñoBono.setVisible(true);
                } else {
                    jLabel27.setVisible(false);
                    jComboBox5.setVisible(false);
                    jLabel28.setVisible(false);
                    jComboBox1.setVisible(false);
                    jLabel29.setVisible(false);
                    jLabel30.setVisible(false);
                    jTextField6.setVisible(false);
                    jComboBox4.setVisible(false);
                    jbtGuardarBono.setVisible(false);
                    jLabel31.setVisible(true);
                    jtxtAñoBono.setVisible(false);
                }

                //activacion para admin
                if (us.isAdmin()) {
                    jbtManUser.setEnabled(true);
                    jbtConfig.setEnabled(true);
                    jbtMantSucPorcentaje.setEnabled(true);
                } else {
                    jbtManUser.setEnabled(false);
                    jbtConfig.setEnabled(false);
                    jbtMantSucPorcentaje.setEnabled(false);
                }

                if (us.isGuardar()) {
                    jtxtPresupuesto.setVisible(true);
                    jcDetalle.setVisible(true);
                    jcboDoctor.setVisible(true);
                    jtxtPaciente.setVisible(true);

                    jtxtBoleta.setVisible(true);

                    jcbLaboratorio.setVisible(true);
                    jtxtRayos.setVisible(true);
                    jcboFechaIngreso.setVisible(true);
                    jtxtTotalPagado.setVisible(true);
                    jtxtTotalLab.setVisible(true);
                    jtxtValorPresupuesto.setVisible(true);
                    jTextField15.setVisible(true);

                    jcbInfo_Odon1.setVisible(true);
                    jcbInfo_Odon2.setVisible(true);
                    jComboBox7.setVisible(true);
                    jTextField9.setVisible(true);
                    jTextField10.setVisible(true);
                    jTextField11.setVisible(true);
                    jComboBox8.setVisible(true);

                    jComboBox9.setVisible(true);
                    jTextField12.setVisible(true);
                    jtxtPago.setVisible(true);
                    jbtGuardar.setVisible(true);
                    jlOcultarIngreso.setVisible(false);

                } else {
                    jtxtPresupuesto.setVisible(false);
                    jcDetalle.setVisible(false);
                    jcboDoctor.setVisible(false);
                    jtxtPaciente.setVisible(false);
                    jbtGuardar.setVisible(false);
                    jtxtBoleta.setVisible(false);
                    jtxtPago.setVisible(false);
                    jcbLaboratorio.setVisible(false);
                    jtxtRayos.setVisible(false);
                    jcboFechaIngreso.setVisible(false);
                    jtxtTotalPagado.setVisible(false);
                    jtxtTotalLab.setVisible(false);
                    jtxtValorPresupuesto.setVisible(false);
                    jTextField15.setVisible(false);
                    jTextField14.setVisible(false);
                    jlOcultarIngreso.setVisible(true);
                }

                if (us.isVerbono()) {
                    jSeparator4.setVisible(true);
                    jComboBox2.setVisible(true);
                    jComboBox3.setVisible(true);
                    jtxtAñoBono.setVisible(true);
                    jbtVerBono.setVisible(true);
                    jScrollPane4.setVisible(true);

                } else {
                    jSeparator4.setVisible(false);
                    jtxtAñoBono.setVisible(false);
                    jComboBox3.setVisible(false);
                    jComboBox2.setVisible(false);
                    jbtVerBono.setVisible(false);
                    jScrollPane4.setVisible(false);

                }
                if (us.isVer()) {
                    jLabel6.setVisible(true);
                    jLabel1.setVisible(true);
                    jbtBuscarDoctor.setVisible(true);
                    jcboDoctorBuscar.setVisible(true);
                    jTextField1.setVisible(true);
                    jLabel7.setVisible(true);
                    jcboFecha.setVisible(true);
                    jtxtAño.setVisible(true);


                    jScrollPane2.setVisible(true);

                    jLabel5.setVisible(true);
                    jTextField5.setVisible(true);
                    jLabel3.setVisible(true);
                    jTextField2.setVisible(true);
                    jLabel10.setVisible(true);
                    jTextField4.setVisible(true);
                    jLabel23.setVisible(true);
                    jTextField16.setVisible(true);
                    jLabel4.setVisible(true);
                    jTextField3.setVisible(true);
                    jLabel46.setVisible(true);
                    jTextField24.setVisible(true);
                    jLabel45.setVisible(true);
                    jTextField23.setVisible(true);

                } else {
                    jLabel6.setVisible(false);
                    jLabel1.setVisible(false);
                    jbtBuscarDoctor.setVisible(false);
                    jcboDoctorBuscar.setVisible(false);
                    jTextField1.setVisible(false);
                    jLabel7.setVisible(false);
                    jcboFecha.setVisible(false);
                    jtxtAño.setVisible(false);

                    jScrollPane2.setVisible(false);

                    jLabel5.setVisible(false);
                    jTextField5.setVisible(false);
                    jLabel3.setVisible(false);
                    jTextField2.setVisible(false);
                    jLabel10.setVisible(false);
                    jTextField4.setVisible(false);
                    jLabel23.setVisible(false);
                    jTextField16.setVisible(false);
                    jLabel4.setVisible(false);
                    jTextField3.setVisible(false);
                    jLabel46.setVisible(false);
                    jTextField24.setVisible(false);
                    jLabel45.setVisible(false);
                    jTextField23.setVisible(false);
                }
                if (us.isLiquiMes()) {
                    jSeparator5.setVisible(true);
                    jcbInfo_Odon1.setVisible(true);
                    jTextField9.setVisible(true);
                    jbtExExcelDr.setVisible(true);
                    jComboBox7.setVisible(true);
                } else {
                    jSeparator5.setVisible(false);
                    jcbInfo_Odon1.setVisible(false);
                    jTextField9.setVisible(false);
                    jbtExExcelDr.setVisible(false);
                    jComboBox7.setVisible(false);
                }
                if (us.isLiquiAño()) {
                    jSeparator6.setVisible(true);
                    jcbInfo_Odon2.setVisible(true);
                    jTextField10.setVisible(true);
                    jbtExExcelDr1.setVisible(true);
                } else {
                    jSeparator6.setVisible(false);
                    jcbInfo_Odon2.setVisible(false);
                    jTextField10.setVisible(false);
                    jbtExExcelDr1.setVisible(false);
                }
                if (us.isLiquiTodos()) {
                    jSeparator8.setVisible(true);
                    jComboBox8.setVisible(true);
                    jTextField11.setVisible(true);
                    jbtExExcelDr2.setVisible(true);
                } else {
                    jSeparator8.setVisible(false);
                    jComboBox8.setVisible(false);
                    jTextField11.setVisible(false);
                    jbtExExcelDr2.setVisible(false);
                }
                if (us.isLiquiGerencia()) {
                    jSeparator7.setVisible(true);
                    jComboBox9.setVisible(true);
                    jTextField12.setVisible(true);
                    jbtExExcelDr3.setVisible(true);
                } else {
                    jSeparator7.setVisible(false);
                    jComboBox9.setVisible(false);
                    jTextField12.setVisible(false);
                    jbtExExcelDr3.setVisible(false);
                }
//                if (us.isEliminar()) {
//                    setEliminar(true);
//                    jCheckBox1.setSelected(true);
//                   System.out.println(this.isEliminar()+" manda!!!!");
//                } else {
//                    setEliminar(false);
//                    jCheckBox1.setSelected(false);
//                }
                if (us.isEliminarMes()) {
                    jtbActivarMeses.setEnabled(true);
                } else {
                    jtbActivarMeses.setEnabled(false);
                }
                if (us.isCerrarMes()) {
                    jlbCerrar_sucursal.setVisible(true);
                    jcbCerrar_mes.setVisible(true);
                    jtxtCerrar_Año.setVisible(true);
                    jButton6.setVisible(true);
                    jButton6.setEnabled(true);
                } else {
                    jlbCerrar_sucursal.setVisible(false);
                    jcbCerrar_mes.setVisible(false);
                    jtxtCerrar_Año.setVisible(false);
                    jButton6.setVisible(false);

                }
            }
        }
        if (entra) {
            JOptionPane.showMessageDialog(this,
                    "Usuario o Contraseña Incorrectas",
                    "Error",
                    JOptionPane.WARNING_MESSAGE);
        }
        this.seguridad();

    }

    public boolean validaAño(String Jaño) {
        boolean x = true;
        try {
            int año = Integer.parseInt(Jaño);
            if (año >= 2010) {
            } else {
                x = false;
            }
        } catch (Exception ex) {
            x = false;
        }
        return x;
    }

    public String getUser() {
        return jtxtUser.getText();
    }

    public void singleAPP() {
        if (faño.format(fechaActual).toString().equalsIgnoreCase("2019")) {
            System.exit(0);
        }
        try {
            serverSocket = new java.net.ServerSocket(9988);
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this,
                    "Ya esta en Ejecucion",
                    "Error",
                    JOptionPane.WARNING_MESSAGE);
            System.exit(0);
        }
    }
}
